Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSRS Formula or expression to change NaN to 0

I am using the following expression to work out a percentage:

=Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name")

Days.Value is showing as 0 however in a few of my results instead of reading 0% in my percentage column it is actually reading NaN (Not a Number).

Does anyone know the exact expression forumla i need and where I should paste it in my current expression to say "Where NaN is showing, put a '0' instead?"

(See image)enter image description here

like image 845
JsonStatham Avatar asked Jan 12 '12 14:01

JsonStatham


People also ask

How do I fix NaN in SSRS?

The best solution to resolve this problem is to create a custom function. IsNothing() is used to avoid #Error and check whether the divisor or the dividend are 0 to avoid NaN and Infinity. Next you can update the fields textbox properties to make the number display as a percentage.

How do you handle null values in SSRS expression?

If we are getting the data from a Database, we can use ISNull or COALESCE function to replace Null values with values we would like. But if we want to replace the Null/Blank values in SSRS Report, we need to use IIF and Isnothing functions in expressions.

How do you write an if expression in SSRS?

Value = “CA”, “Bold”, “Italic”) SSRS iif statement The format of the IIF() statement is as follows: =IIF(Expression, Condition set when the expression is true, Condition set when the expression is false) It should be a Boolean expression, according to parameter 1.

How do you break a line in SSRS expression?

Tip 6: Adding a Line Break in SSRS Expressions Developers use multiple text boxes to show multiline data otherwise a single TextBox can be used with just a line break. The VbCRLf (Visual Basic Carriage Return Line Feed) value can be used to add a line break in expressions.


1 Answers

I didn't have luck with the above answers. Here's what worked for me:

=IIF(Single.IsNAN(Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name")), 0, Fields!Days.Value/Sum(Fields!Days.Value, "Date_month_name"))
like image 73
hurleystylee Avatar answered Sep 18 '22 13:09

hurleystylee