In these last days I’ve been working on a BI solution for a logistic company. One report I have to create has a particular behavior that can make life a little complex if you’re using Reporting Services: the value used in rows and column totals is not calculated in any way, but is just taken from the database (SSAS in this case), just like any other cell value:
I’ve found this business case in a report that shows all the target values that a salesman has to reach. The total value for a month is not the average nor the sum of the target values for all the regions, but is just a fixed value set by someone (his manager, normally :-)) that represents that overall expected target for that month.
The data returned from the database (no matter if using MDX or SQL; in this example I’m using T-SQL but in reality I’m using MDX) look like the following:
The null values in the region column represents the “total” value for that month, while for date (which is stored in a yyyymmdd integer format), as you may guess, the values for year are represented by the rows with value “0” in the month part.
If you just use these values in a Tablix, using the
this is what you obtain:
clearly the column “20090000” and the no-name row are in the wrong place, since they should be shown as the last and the rightmost values, just like what normally happens with totals.
How to do that? The anwser lies in the usage of Adjacent Groups and Group Filters.
The first step is to remove that row and column from the data. This can be done specifying a filter for the existing groups.
For the reference_data group you just have to say that you want to filter out all the data related to the 20090000 value:
For the region, since we’re using a null value, we have to use a little trick since the operator “is” is not available.
In the Filter Expression field we have to specify something that will turn null to True or False:
=(Fields!region.Value Is Nothing)
then in the Value field you just have to specify “True” (or False if you’re using the “=” operator):
Now, the matrix won’t display the “total” row and column. To show where we want we just have to add one Adjacted Group for columns and one for rows:
So that at the end the matrix will look like this:
Now, if you run the report, the result will be the one we expect: