In the last article we prepared a simple report returning all rows from SQL Server dataset (Part 4 – Creating report SSRS). It displays sales data in form of a simple table. We made a promise not to make the report too complicated but we still want to do one important thing. Report returning the table with all rows is not user friendly because it cannot be filtered. This article will focus on how to make a parameter/filter configuration in SSRS, that enables filters.

Setting Parameter for filter in SSRS

After last article, our report should look like the one in the picture (sorry about a czech labels – original post is written in Czech – it contains Year, Month, Product, Product category, Product subcategory, Revenue amount, Numer of orders)

Lets keep things not complicated. We want to use “Year” column as filtr in way user can to roll down a filter list and then select year.

Create dynamic SSRS Filter

Each filter contains some value selection. List of values can be created manually just by writing values. But this is not sexy at all. We want the report to be dynamic. It may happen that you take care of tens of reports in your company and if you do not have these filters dynamic, it will take a lot of time to take care of each report and update its values.

Let’s create a dynamic dataset which will load list of all possible values while filtering the report. Remember the part of our miniseries with dataset. We used script ad to define dataset [1]. SQL query for dataset (Filter year) will logically look like this [2] just a distinction of year column.

[1] SQL Query – Table dataset definition from previous tutorial
 SQL Query - filter dataset definition
[2] SQL Query – filter dataset definition for parametrization
Now we create a new dataset in the report using our filter dataset [3], [4]

New dataset for the filter in SSRS reporting services
[3] New dataset prepared for our filter
SSRS filter Dataset has been created successfully
[4] SSRS filter Dataset has been created successfully

Configuring Parameter Definition in Reporting Services

Year filter dataset is ready, we can proceed to configuring the parameter. Parameters are accessible from Report data card. Select Parameters, then select Add parameter [5]. Name the parameter on the next screen and select Integer data type [6]. Click on the Available Values in the nect step and choose Get values from a query [7]. Finally confirm the parameter configuration. After clicking on Preview, report requires us to fill in filter year [8].

New Parameter in SSRS reporting services
[5] New Parameter
SSRS Parameter data type configuration
[6] Parameter data type configuration
Connecting parameter with dataset in SSRS reporting services
[7] Connectiong parameter to dataset
Successful parameter configuration in ssrs reporting services
[8] Successful parameter configuration

Connecting SSRS Filter with Main Dataset

Now we have a filter dataset offering values dynamically. The final step we are going to do is to connect the parameter to our main dataset = table. But it is easy. Edit main dataset and add some code into SQL query section as shown below. It will limit the result to whatever is currently selected in the filter (@Rok is the name of our filter) [9].

Linking Parameter with a SQL query is defined in dataset properties –  @ParameterName  Click on card Parameters and link both values both values together as shown in the picture. [10]

Connecting parameter with main dataset in ssrs reporting services
[9] Connecting parameter with main dataset
[10] Finalizing settings dataset to parameter
And it is done. SSRS parameter configuration is complete. Report should react to filter like a charm.

Nastavení parametru v SSRS

Next part will be focused on  Part 6 – Report deploy in SSRS

5/5 - (1 vote)

Ing. Jan Zedníček - Data Engineer & Controlling

My name is Jan Zedníček and I have been working as a freelancer for many companies for more than 10 years. I used to work as a financial controller, analyst and manager at many different companies in field of banking and manufacturing. When I am not at work, I like playing volleyball, chess, doing a workout in the gym.

🔥 If you found this article helpful, please share it or mention me on your website

Leave a Reply

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