is it necessary to replace nan values with mean or mode or median or any other value? - data-analysis

I have a dataset conaining about 18 million records. Is it necessary to replace nan values with mean or mode or median or any other value? Is it a good practise to keep nan values as it is and simply ignore nan values during data analysis?

Related

Populate a cell in SSRS report by testing value conditions from other column value

Populate a cell in SSRS report by testing value conditions from other column values
I have 3 columns (category, Month, Amount) in my dataset, with values similar to these below:
Category Month Amount
A Jan 20
A Feb 25
A Mar 10
R Jan 15
R Feb 50
R Mar 55
On the report I need:
Jan Feb Mar
A 20 25 10
R 15 50 55
I have tried placing this expression in each group row column, for example, in the "Feb" column it would be:
=IIF(Fields!Category.Value = "A" and Fields!Month.Value = "Feb", Fields!Amount.Value, 13)
Using IIF, which does not short-circuit, is not evaluating the conditions properly. The "Month" value being a string, it displays always the first row found for the conditions, in this case it would display value 20, instead of 25. If I change the "Month" value to int, it displays the false(13);
How can I populate my cell correctly, using IIF or something other way?
Any help on this is deeply appreciated.
You don't need to do anything like that.
Just use a matrix instead of a table.
Add the matrix to the report, you'll see three placeholder names, (from memory) something like Rows, Column and Data. Drag your Category field to the rows cell, your month field to the columns cell and your Amount field to the data cell. That's it....
The only problem you will have is the columns would be ordered alphabetically by default. It would be better to have the Month number in your dataset too so you can order by that. You set the column order by right-clicking the column group name in the row/column group panel which is under your main report design area.

SSRS Expression: First(Value) but only if Value2 = X

Sorry, not sure how much sense my title makes.
Basically...I have a report and the dataset (Named DataSet1) returns data something sort of like this.
Quarter MonthID Month Value1 Value2 QtrAvgValue1 QtrAvgValue2
Q-1 1 Mar 2017 12 28% 12.3 24.0%
Q-1 2 Feb 2017 15 12% 12.3 24.0%
Q-1 3 Jan 2017 10 32% 12.3 24.0%
Q-2 4 Dec 2016 18 25% 17.3 24.3%
Q-2 5 Nov 2016 14 18% 17.3 24.3%
Q-2 6 Oct 2016 20 30% 17.3 24.3%
The last two columns are just the averages for that rows entire quarter. The [Quarter] column is read like -1 means last quarter, -2 means the quarter before. The MonthID column is just an auto increment that goes up for every month older going back. So the most recent month would be 1, the next month older would be 2.
I need an expression that will let me say something like this:
WHEN Quarter = Q-1 THEN return QtrAvgValue1; Which would return 12.3;
I would also need an expression that could say:
WHEN MonthID = 1 THEN return Value1; Which would return 12;
Is this possible? I would hate to have to pivot my dataset to be a crap ton of columns with ridiculous column names
NOTE: I have tried using IIF with SUM/AVG and it works with numerical values as a sort of hack...but I cannot think of a way to handle string values.
UPDATE: I figured it out, using the Lookup and LookupSet functions in SSRS, which I have never used before.
Example:
=LookupSet("Q-1", Fields!Quarter.Value, Fields!QtrAvgValue1.Value, "DataSet1")(0)
LookupSet is normally used for One to Many relationships, but it will still work in one to one relationships as well.
This expression basically says to look up all rows that have the Quarter of "Q-1" and return the column [QtrAvgValue1].
The Lookup set function puts data into an array, so the "(0)" at the end indicates to use the first value in the array...essentially the same thing as the "First()" function.

Calculate percentage in ssrs report

I have one ssrs report having matrix table which looks like this
YEAR A1 B1 Total percentage
2012 23 11 34
2013 12 12 24
2014 32 43 75
here i need to find percentage using below formula in ssrs expression
(Total of current year-Total of previous year)/(Total of previous year)*100
[for ex take 2012 - (Total for 2012-Total for 2011)/(Total for 2011)*100
The easiest way is to add a column to your data set that had the previous year total. Then you would right click the Percentage field and create an expression like the one above you want to calculate.
Expression Examples
One way easy way would be to use the Function previous, in SSRS this function returns the previous row item. Calculating the percentage would then be something like:
((Previous(Count(Fields!Day.Value))-ReportItems!Textbox22.Value) / ReportItems!Textbox22.Value )
Note: Textbox22.Value would be the base item/count you are comparing as a percentage.

select where in(Float, .....)

I am trying to select some values from mysql with the next sentence:
SELECT
id, lead_id, form_id, field_number, value
FROM
wp_rg_lead_detail
WHERE
field_number IN (6.3, 6.6, 11, 12, 17, 14)
ORDER BY
lead_id, field_number
the field field_number is a float and the select is listing just the 11, 12, 17 and 14 fields but not values from the 6.3 and 6.6
What is wrong with the sentence?
Thanks.
The reason is that 6.3 and 6.6 are not actually stored in your table. Computers cannot perfectly represent most fractional values. When the value stored is compared to 6.3 or 6.6, it does not match, even though it looks like it should. The difference might be at the 9th or 10th decimal place, which you won't normally see.
http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
If you need to exactly compare the values, make them integers or decimals. If nothing will ever have more than 1 number to the right of the decimal point, you can multiply all values by 10 to only work with integers, for example.
There is nothing wrong with the query. The problem is that float is not precise type. Use decimal instead (or change the query to something like ... WHERE (field_number BETWEEN 6.2999 AND 6.3001) OR (field_number BETWEEN 6.5999 AND 6.6001 OR ()... )

How can i Make This Type SSRS

I have a table in data base which has column MonthNo ,Year ,MonthValue ,AvgYTD and it has values in
1 ROW... 1 , 2010 , 2.3 , 4.0 AND
2 ROW... 2, 2010, 3.3 ,5.0 AND
3 ROW.. 3, 2010, 3.3, 7.9
AND I want output in my SSRS.....
WHEN I SELECT MONTH MARCH USING PARAMETER THEN OUTPUT WILL BE....A TABLE AND IT HAS COLUMN
JAN , FEB , MARCH , AVGYTD and values in row are ..
2.3 ,3.3, 4.3, 7.9
Updates
i am using sql server 2005 and 7.9 is th AvgYTD Value comes from table for selected month march....
i want ...if i select month march then output will be show month value of jan,feb and march and AvgYTD value for only selected month..
thanks,
Use a matrix, and if SQL 2005, use the InScope function to be able to tell if you're in the SubTotal column. In SQL 2008 you can just put a column in there for the appropriate YTD value.
Edit, to explain it more thoroughly:
Put a Matrix in the report. Use a column group on Year, MonthNo. By default that group will be called matrix1_ColumnGroup1 (or something like that - go to Edit Group to set it to something better). Put a row group on whatever causes a second row to appear.
In the Cell part of the Matrix, use an expression like:
=IIF(InScope("matrix1_ColumnGroup1"), First(Fields!MonthValue.Value), Last(Fields!AvgYTD.Value))