sqlreporting-servicesnullif

ssrs nullif fully qualified name


I am building a report in SSRS that divides two numbers to get their percentage. There are some values that will be divided by 0, which throws an error. I have this expression to get around the divide by 0 error, but it has to run the equation twice.

=IIF(System.Double.IsNaN(Sum(Fields!ON_TIME.Value)/Sum(Fields!COUNT_FIELD.Value)),Nothing,(Sum(Fields!ON_TIME.Value)/Sum(Fields!COUNT_FIELD.Value)))

In order to speed up performance I would like to run this expression as a NULLIF expression, like this:

=NULLIF(Sum(Fields!ON_TIME.Value)/Sum(Fields!COUNT_FIELD.Value), 'Nan')

When I run the report with this expression I get an error saying "Name 'NULLIF' is not declared". I have been trying to find the fully qualified name for NULLIF, as I think that will solve my problem, but I have not had any luck finding it. Does anyone know what the fully qualified name for NULLIF is, or is there some other way to implement NULLIF in SSRS?

Thanks


Solution

  • NULLIF is a SQL function, not VB. Try just checking for 0 instead:

    =IIF(SSum(Fields!COUNT_FIELD.Value) = 0,
         Nothing,
         Sum(Fields!ON_TIME.Value)/Sum(Fields!COUNT_FIELD.Value)
        )