This week I am switching gears to talk about a cool design technique for the Reporting Services matrix.
At least it is cool to me J and hopefully it will be helpful to you.
In some design scenarios, you may require two “subtotals” for the same group of data that point to different database fields. This is a little tricky with the matrix given that there is one subtotal per matrix group. You can, of course, use the InScope function to apply different subtotal expressions to various groups, but in this scenario, InScope is not immediately helpful because different subtotals are needed for the same group.
I have mocked up a very simplified version of a business scenario where this can occur:
Events
YTD Total
Quarter 1
Quarter 2
Grand Total
Jan
Feb
Mar
Total
Apr
May
Jun
Count of Completed and Planned Events
12
10
5
25
50
…
...
The business requirements behind the table are as follows:
· The Count of Completed and Planned Events is a database field containing the total count of the completed and planned events by month. From a business perspective, they are combined together to calculate the overall event workload.
· The Quarter Totals and Grand Total are normal subtotals of the database field by quarter and year.
· Now the interesting requirement. The YTD Total should only display the total for the Year-To-Date completed events. The completed events measure is actually a different database field that stores completed events by month.
So put simply I need a Grand Total that sums one data field and I need a YTD total that sums a different field.
· To interpret the example data in the table, assume that Today is February 15th. In this scenario, the YTD Total includes the January events (10) and the competed February events as of February 14th (2). The YTD total is 12. There are 3 other remaining events in February.
To solve this problem, I thought of a few different ways to do this on the database side and even considered reverting to a table, but the most appealing to me was to create a dummy group so that I could use InScope J
So the requirement above ended up can be implemented with the design as below.
Year
Here is the trick
For the Data Expression, you can use the InScope expression as follows:
=IIF(InScope("matrix1_GroupYear"), Sum(Fields!TotalCount.Value),Sum(Fields!YTDCount.Value))
So InScope was handy once again with a little bit of extra work to get there!
Hope this helps you in your next matrix report.
Theme design by Jelle Druyts
Pick a theme: BlogXP sqlx BlogXP sqlx
Powered by: newtelligence dasBlog 2.0.7226.0
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Elizabeth Vitt
E-mail