问题
Might be easier to show what I am trying to return and then explain.
REGION STATE SALES
------ ----- -----
WEST WA $ 200
EAST VA $ 175
WEST CA $ 100
EAST NY $ 50
NORTH MI $ 25
NORTH WI $ 20
WEST SUBTOTAL: $300
EAST SUBTOTAL: $225
NORTH SUBTOTAL: $ 45
GRAND TOTAL:$570
While the example above isn't my exact business case, it's close enough to simplify the question.
So, using the sample data above, my report can be ran by one or more regions. In this example, I ran it for regions west, east and south. The report sorts the detail data by total sales, with the highest sales at the top. Following the detail data, I'd like to get a subtotal of the regions' totals. If I ran for two regions, then I'd get two subtotal lines. Then finally, a grand total.
This would be easy if I was grouping by region, but I'm not; I want the detail to remain sorted by sales regardless of region. How can I achieve this? The tricky part is the dynamic number of subtotal lines.
I'm running SSRS 2012.
回答1:
You can do this in the one table based on your existing Dataset using an Adjacent Group based on REGION.
Say you have a simple table like:

To add the REGION subtotals, right click on the detail row and select Add Group -> Adjacent Below...:

The end result should look something like:

i.e. the group row is directly after all the detail rows.
In my case I set the expression to =Fields!REGION.Value & " Sub Total:"
and set the new group to sort by =Sum(Fields!SALES.Value)
from high to low.
Seems to work as required, give or take some formatting:

来源:https://stackoverflow.com/questions/17682757/report-subtotals-without-grouping