2013-05-13 131 views
1

默認情況下,SSRS中的SUM函數排除空值。我希望能夠檢查詳細信息組中的任何NULL值並在摘要組中引發錯誤。在詳細視圖中,我用它來檢查NULLS:如何在SSRS中使用SUM函數時檢查NULL值

=IIF(IsNothing(Fields!EquityPrice.Value)) ,"#Error", Fields!EquityPrice.Value*Fields!EquityShares.Value) 

這可以根據需要工作。

當我在摘要部分使用它時,它會忽略NULLS並返回非空值的SUM。我想返回「#錯誤」,而不是:

=IIF(IsNothing(SUM(Fields!EquityPrice.Value))) ,"#Error", SUM(Fields!EquityPrice.Value*Fields!EquityShares.Value)) 

我試圖消除了「IsNothing」表達,但無濟於事總和。任何幫助,將不勝感激。提前致謝!

回答

2

因此,只需確認一下,如果組中至少有一個NULL值,應該顯示#Error

您可以使用摘要表達如下:

=IIf(Sum(IIf(IsNothing(Fields!EquityPrice.Value),1,0)) > 0 
    , "#Error" 
    , Sum(Fields!EquityPrice.Value * Fields!EquityShares.Value)) 

這將創建NULL值的計數 - 如果計數大於零,則返回#錯誤

我做了一個簡單的報告進行測試:

enter image description here

​​

這將使用你的表達在在總結的詳細程度和礦山。根據需要,用於與一個NULL值的組錯誤:

enter image description here

+1

純邏輯。謝謝! – user1171915 2013-05-13 20:59:07