开发者

this expression always print #Error

开发者 https://www.devze.com 2023-01-04 01:17 出处:网络
This expression always print #Error on my report =IIF(ISNOTHING(Fields!f2.Value),\" \", Fields!f2.Value* Fields!If3.V开发者_开发问答alue)

This expression always print #Error on my report

=IIF(ISNOTHING(Fields!f2.Value)," ", Fields!f2.Value* Fields!If3.V开发者_开发问答alue)


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
0

精彩评论

暂无评论...
验证码 换一张
取 消