Dot-Net
SSRS 2005 中的字元串聚合
使用 BIDS 2005 創建 rdl 報告。我想讓報告聚合數據組中的所有字元串。我一直在尋找類似 Concatenate(Fields!CompanyName.Value, “,”) 或 Join 或等效的東西。但它必須遍歷給定範圍內的所有記錄。
我正在以日曆格式創建使用者活動的報告(看起來像Google的月視圖日曆)但是如果使用者在一天中有多項活動,我希望所有活動都顯示在同一個“日框”中。這是需要聚合的問題還是有其他方法可以讓 SSRS 報告執行此操作,我試圖想辦法讓矩陣為我做這件事,但我碰壁了。
在 SSRS 中進行聚合連接的常用方法是使用自定義程式碼。請參閱此處的範例:
http://blogs.msdn.com/suryaj/archive/2007/08/11/string-aggregation.aspx
這是基本形式的自定義程式碼:
Private CurrGroupBy As String = String.Empty Private ConcatVal As String = String.Empty Public Function AggConcat(GroupBy as String, ElementVal as String) as String If CurrGroupBy = GroupBy Then ConcatVal = ConcatVal & ", " & ElementVal Else CurrGroupBy = GroupBy ConcatVal = ElementVal End If Return ConcatVal End Function在要顯示的分組級別後跟此表達式:
=RunningValue( Code.AggConcat( Fields!YourFieldToGroupBy.Value , Fields!YourFieldToConcat.Value ) , Last , "YourGroupName" )“YourGroupName”通常是“table1_Group1”,如果它是您在報告中創建的第一個表和第一個組,並且您沒有指定不同的名稱。