2014-02-28 24 views
1

我甚至不確定是否可以這樣做,因爲SSRS有很多限制。使用分組時比較值與另一個值

假設我有我的SQL表的兩個條目:

Name: John Doe 
Value: 20 
Month: January 2014 

Name: John Doe 
Value: 30 
Month: February 2014 

我試圖做依靠,如果值或比前一個月上升了一些條件格式。

現在我正在分組月。有沒有辦法以某種方式比較分組中的前一個值與當前值?例如:

=IIF(Fields!Month.Value < (Fields!Month.Value-1)) ... 

這看起來好像只取當前月份的值並給出之前的月份。

想法?

編輯:嘗試'上一個'命令後,它越來越接近我正在尋找。 但是...它比較來自其他人的字段。 (該數據是由人進行分組,然後按月份)

例如:

Name: John Doe 
Value: 20 
Month: January 2014 

Name: John Doe 
Value: 30 - WOULD BE GREEN BECAUSE 30 > 20 
Month: February 2014 

Name: Steve Smith 
Value: 10 - WILL SHOW RED BECAUSE 10 < 30 (different person) 
Month: January 2014 

Name: Steve Smith 
Value: 20 
Month: February 2014 

回答

1

您可以用Previous功能做到這一點。

說我有數據是這樣的:

enter image description here

並且基於該表,對month分組:

enter image description here

我已經應用了下面的表達式來的一個文本框:

=IIf(Previous(Sum(Fields!val.Value), "monthGroup") > Sum(Fields!val.Value) 
    , "Red" 
    , "Green") 

對我來說,表達式編輯器顯示一個語法錯誤,但罰款跑:

enter image description here

你可以爲其他的格式要求適應這一點。

+0

偉大的答案伊恩!看到我的編輯進一步的幫助? – George