0

I have an SSRS expression where sometimes the denominator is 0, and I get a #DIV error so I added a +.0001 to eliminate the #DIV error, but when I add a FLOOR syntax I get an #ERROR, and I can't figure out to remove the #ERROR. The result should be NULL is I add the FLOOR syntax.

Code 1 without FLOOR:

=IIF(Sum(Fields!Handled.Value) > 0, Sum(Fields!talktime.Value) / Sum(Fields!Handled.Value+.0001), "")

Code 2 with FLOOR:

=FLOOR(IIF(Sum(Fields!Handled.Value) > 0, Sum(Fields!talktime.Value) / Sum(Fields!Handled.Value+.0001), ""))
Arsee
  • 651
  • 2
  • 11
  • 36

1 Answers1

0

To eliminate the divide by zero error you would need to add the following custom code to your report:

Function CalculateFraction(ByVal Numerator As Double, ByVal Denominator As Double) As Double

If Denominator = 0 Then CalculateFraction = 0 Else CalculateFraction = Numerator / Denominator End If Return CalculateFraction End Function

And then insert the following expression into the desired textbox and format according:

=Code.CalculateFraction(Fields!Numerator.Value, Fields!Denominator.Value)

SuperSimmer 44
  • 964
  • 2
  • 7
  • 12
  • figured it out. IIF(Sum(Field)>0,Floor(Sum(Field) / iif(Sum(Field)>0,sum(Field),-1)), "") – Arsee Nov 18 '16 at 04:38