SSRS Groups, Aggregated Group after detailed ones

拜拜、爱过 提交于 2019-12-13 05:37:59

问题


in SSRS, I try to create a group structure as in the example below (months have only 5 days here for simplicity). The tricky issue is the last column "Sales(monthly)": It should be a Row Group, grouping by month, after the more detailed columns "Day" and "Sales(daily)". It would be no problem to have this column as the second one between "Month" and "Day" column.

But after being already on the "detail level" with "Day" and "Sales(daily)", I cannot create another more aggregated group. And if I just set Group Properties, Group On to Month for the 4th column, then "Day" and "Sales(daily)" also appear aggregated with only 1 row per month.

Does anybody know how to solve this? Or is this just not possible in SSRS?

Month  Day   Sales(daily)  Sales(monthly)
Feb    1     100           615
       2     150
       3     130    
       4     125    
       5     110    
March  1     100           685
       2     150    
       3     200    
       4     125    
       5     110    
April  1     100           560
       2     150    
       3     75 
       4     125    
       5     110    

Many thanks Mike


回答1:


There's not a native way to do this in SSRS.

You would need use LookupSet to get the daily sales for the month and then use a custom function (SumLookup) to get the total.

Then you need to use an IIF so that you only display it on DAY 1.

=IIF(Fields!DAY.VALUE <> 1, NOTHING, 
Code.SumLookup(LookupSet(Fields!MONTH.Value, Fields!MONTH.Value, Fields!SALES.Value, "Dataset1")))

Function code:

Function SumLookup(ByVal items As Object()) As Decimal

If items Is Nothing Then Return Nothing

Dim suma As Decimal = New Decimal()
Dim ct as Integer = New Integer()

suma = 0
ct = 0

For Each item As Object In items

  suma += Convert.ToDecimal(item)
  ct += 1

Next

If (ct = 0) Then return 0 else return suma 

End Function 

SSRS:

Use LookupSet to retrieve a set of values from the specified dataset for a name-value pair where there is a 1-to-many relationship. For example, for a customer identifier in a table, you can use LookupSet to retrieve all the associated phone numbers for that customer from a dataset that is not bound to the data region.



来源:https://stackoverflow.com/questions/36482102/ssrs-groups-aggregated-group-after-detailed-ones

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!