2010-06-21 58 views
0

這種表達總是打印#錯誤在我的報告這種表達總是打印#錯誤

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

我猜你想乘非數字數據。 f2和f3的數據類型是什麼? – AlexCuse 2010-06-21 18:24:09

+0

這個問題是爲[報告查看器表達式]的答案(http://stackoverflow.com/questions/3087082/report-viewer-expression) – gbn 2010-06-21 19:09:00

回答

0

到IIF中的參數都進行評估,不論測試的值。讓我們分解表達式來看看會發生什麼。

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 

試試這個:

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

在這種情況下,當F2爲null這裏發生了什麼:

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

'SWITCH'也表現出同樣的行爲嗎? 「SWITCH」中的每個子句都評估過嗎? – SouravA 2015-01-22 12:10:15

+1

它適用於IIF(),因爲它是一個函數調用。就像任何其他函數調用一樣,參數被評估並傳遞給函數。 SSRS中的SWITCH()也是一個函數調用,所以是的。每次都會評估所有參數。 – 2015-01-22 13:37:24