views:

15

answers:

1

This expression always print #Error on my report

Plz help

=IIF(ISNOTHING(Fields!f2.Value)," ", Fields!f2.Value* Fields!If3.Value)
A: 

The parameters to IIF are always evaluated regardless of the value of the test. Let's break up the expression to see what happens.

P1 = ISNOTHING(Fields!f2.Value) // this gets evaluated and "True" is the value
P2 = Fields!f2.Value * Fields!If3.Value // this gets evaluated and throws an #Error
Result = IIF(P1," ",P2) // this never gets evaluated because an error is already thrown

try this instead:

=IIF(ISNOTHING(Fields!f2.Value)," ", IIF(ISNOTHING(Fields!f2.Value),0, Fields!f2.Value) * Fields!If3.Value)

In this scenario, when f2 is null here's what happens:

P1 = ISNOTHING(Fields!f2.Value) // this gets evaluated and "True" is the value
P2 = IIF(P1,0, Fields!f2.Value) // this gets evaluated and 0 is the value
P3 = P2 * Fields!If3.Value // this gets evaluated and 0 is the value
Result = IIF(P1, " ", P3) // this gets evaluated and " " is the result
JC