Search code examples
reporting-servicessyntaxreportbuilder3.0iifssrs-expression

IIF statement error when divding by 0


Ok so I have an #ERROR when dividing by 0 so I have tried to capture this using the following code

=IIf(Code.SumLookup(LookupSet(Fields!region.Value, Fields!region.Value, Fields!X.Value, "Dataset2")))=0,"-", Fields!Bad.Value/(Code.SumLookup(LookupSet(Fields!region.Value, Fields!region.Value, Fields!ticket_count.Value, "Dataset2")))

So this should do the following: If [value in FieldsX in "Dataset2"] = 0, then show a "-" , else do the calculation [Fields!Bad.Value/FieldX in "Dataset2"]

But for some reason this just fails upon attempting to run: [BC30455] Argument not specified for parameter 'FalsePart' of 'Public Function IIf(Expression As Boolean, TruePart As Object, FalsePart As Object) As Object'.

Is there something wrong with how I have formatted the Iif statement? Because the false calculation runs fine when used independently.

Any Ideas?


Solution

  • Check your brackets properly. It's not proper. Below code may work for you.

    =IIf(Code.SumLookup(LookupSet(Fields!region.Value, Fields!region.Value, Fields!X.Value, "Dataset2"))=0,"-", Fields!Bad.Value/(Code.SumLookup(LookupSet(Fields!region.Value, Fields!region.Value, Fields!ticket_count.Value, "Dataset2"))))