0

Anyone know why the following expression would make my cell just say "#ERROR"?

=IIf(Sum(Fields!curr.Value) = 0, 0, Sum(Fields!due.Value) / Sum(Fields!curr.Value))

Is it not short circuiting so it still hits the division by zero? If so, would there be a way around this?

Glen
  • 11
  • 2

1 Answers1

0

Microsoft thinks they are smarter than you and are checking for a divide by zero even though you'll never hit it because of your logic.

The Trick (i.e. Workaround for Microsoft's propensity for "helping" and making things worse) is to use another IIF:

=IIf(Sum(Fields!curr.Value) = 0, 0, Sum(Fields!due.Value)) / IIF(Sum(Fields!curr.Value) = 0, 1, Sum(Fields!curr.Value))

SSRS Expression Divide by Zero Error

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/ef1a0375-414e-41f4-b32f-3b782c5b4c85/error-using-iif-and-divide-by-zero?forum=sqlreportingservices

Community
  • 1
  • 1
Hannover Fist
  • 10,393
  • 1
  • 18
  • 39