SSRS Expression Divide by Zero Error

后端 未结 3 1929
不知归路
不知归路 2020-11-27 05:46

I have a tablix box that has a division expression. When dividing by zero or nulls I get #Error displayed in my report. I tried to create an IIF st

3条回答
  •  青春惊慌失措
    2020-11-27 06:42

    To avoid the overhead of maintaining code, the solution below feels tidiest to me. It avoids the division by zero in the denominator by adding the smallest possible Double value to it (Double.Epsilon, which is 4.94e-324). This value's way too small to affect the value of the fraction for anything people would use SSRS for. It also avoids nesting IIF functions.

    =IIF(Sum(Fields!Denominator.Value)>0, 
         Sum(Fields!Numerator.Value)/(Sum(Fields!Denominator.Value)+Double.Epsilon),
         nothing)
    

提交回复
热议问题