Dataset and tablix filtering in SSRS

Problem

I’m creating a SQL Server Reporting Services (SSRS) report based on datasets that I have no control over and they have more data in the result set than what is required for the report. Is there a way that I can filter the datasets inside the SSRS report itself?  Check out this tip to learn more.

Solution

You may run into situations when a dataset provides more information than what is needed for a report. Thankfully, data can be filtered in a few locations in a report. The first is at the dataset level. In order to filter the dataset right-click on the dataset and Choose Dataset Properties:

SQL Server Reporting Services Dataset Properties

Once the Dataset Properties window opens choose Filters:

SQL Server Reporting Services Dataset Filtering

Select one of the fields in the dataset:

SQL Server Reporting Services Dataset Filtering

Select the type of filtering you want:

SQL Server Reporting Services Dataset Filtering

Finally, enter the criterion for the filter and click OK.

Another location where a dataset can be filtered is in a table, or tablix. The interface for setting up filtering at the tablix level is similar to setting it up for the dataset. The only differences are:

1. The DataSetName property of the tablix should be set to the relevant dataset:

Setting the DatasetName property of the Tablix in SQL Server Reporting Services

2. When you click inside a tablix an outer rectangle will appear with a square in the upper left-hand corner. Right-click the square and choose Tablix Properties:

Accessing the properties of the Tablix in SQL Server Reporting Services

For the example I am building a report that will display weather observations for selected sites around the Atlanta area; however, I want each site to be shown separately (the data was collected from the National Weather Service). I have two datasets available-one that has information about the collection sites and another that has the actual weather conditions for the sites. Below are samples of each dataset:

Site Information
Site Information queried in SQL Server Management Studio

Weather conditions
Weather conditions queried in SQL Server Management Studio

Notice in each dataset that there are multiple sites. In general I will create two tablixes per site: one to show information about the site and the other to show the observations for the site. Below is an example of the filters where I’m filtering on a particular Site ID:

Sample Site filtering in SQL Server Reporting Services

Below is a sample of the final report rendering, showing that each area has been filtered by Site ID:

Final Report Rendering

Next Steps

Leave a Reply

Your email address will not be published. Required fields are marked *