0

In my visual studio report I have a sum of 2 textboxes that when calculated shows 'NaN'. The reason it does this is because the calculation for certain projects is 0.

 My simple calculation is Textbox 1 / Textbox 2.

Is there a way I can code it to show 0.00 or show blank instead of NaN when a certain type of project is selected from the drop down parameters?

I cannot have a seperate report for different prioject types as they are linked into the same overall Totals.

any advice appreciated.

user1086159
  • 1,045
  • 5
  • 16
  • 24
  • Also see this similar question for some more solutions: http://stackoverflow.com/questions/10432714/divide-by-zero-null-workaround-in-ssrs-2008-report/10441532#10441532 – Nathan Griffiths May 09 '13 at 03:19

2 Answers2

2

Change the formula to an Iif statement where you evaluate the two textboxes. You need to make sure that both are numeric and that the divisor is not zero. If any of those are true, then set the value to 0.00 ELSE do the calculation.

Declan_K
  • 6,726
  • 2
  • 19
  • 30
  • =IIf(IsNothing(ReportItems!textbox21.Value)Or IsNothing(ReportItems!textbox19.Value),0,((ReportItems!textbox21.Value)/(ReportItems!textbox19.Value))) – user1086159 May 08 '13 at 14:25
0

You can check for conditions where the calculation creates NaN (eg. Divide by Zero) and manually set the resultant answer to 0 instead of using the NaN.

Trugath
  • 188
  • 1
  • 7