THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Davide Mauri

A place for my thoughts and experiences the Microsoft Data Platform

Custom Aggregations Values in SQL Reporting Services with Tablix Filters

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:


Published Friday, July 24, 2009 4:20 PM by Davide Mauri
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS



Elena said:

Hi Davide,

I have a similar set of data and my NULLs are labeled as "Total".

In  your example, is there a way to calculate the % from that Total for instance to understand performance of each Region/Period against the target?

Thank you


December 13, 2013 3:26 AM

abx said:


May 31, 2018 11:08 PM

Leave a Comment


About Davide Mauri

Director of Software Development & Cloud Infrastructure @ Sensoria, an innovative smart garments and wearable company. After more than 15 year playing with the Microsoft Data Platform, with a specific focus on High Performance databases, Business Intelligence, Data Science and Data Architectures, he's now applying all his skills to IoT, defining architectures to crunch numbers, create nice user experiences and provide meaningful insights, all leveraging Microsoft Azure cloud. MVP on Data Platform since 2006 he has a very strong background development and love both the ER model and OO principles. He is also a fan of Agile Methodology and Automation, which he tries to apply everywhere he can, to make sure that "people think, machines do".

This Blog


Privacy Statement