A client of mine emailed a report, designed in SQL Server Reporting Services 2005, that when compiled produced a "Divide by Zero" error message.
When looking at the report, the formula generating the error message was in the format:
=IIF ({Tablename.Fieldname2} = 0 , 0, {Tablename.Fieldname1}/{Tablename.Fieldname2}) The IIF function has the same arguments as the Microsoft IF function, and is used in the same way to test the value of the denomination.
Unfortunately in SQL Services Reporting Services, the IIF function evaluates all the arguments before it executes, therefore, the formula above may still generate a divide by error message
To get around this issue, the above formula has to be modified to:
=IIF ( {Tablename.Fieldname2} = 0 ,0, {Tablename.Fieldname1}/ IIF( {Tablename.Fieldname2} = 0 , 1, {Tablename.Fieldname2}))
|