In SQL Server Reporting Services, Filters are similar to the SQL WHERE Clause. SSRS Dataset level Filters are used to restrict the Records displayed by the Reports. This article will show you the steps involved in applying filters at the Dataset Level in SSRS (SQL Server Reporting Services) with an example.
It supports two types of Filters: Filters at the Tablix Level and Filters at the Dataset Level. If you want to use the SSRS filters on multiple reports, apply filters at the shared Dataset level. It will apply to all the tables using that Dataset. Please refer to the WHERE Clause article.
We use the below-shown report to explain SSRS filtering the data at the Dataset level. Please refer to Table Report to understand the Shared Data Source and Dataset we used for this SSRS report. If you observe the below screenshot, It was a regular report with Product Name, Color, Sales, and Tax Amount columns.
If you observe the above screenshot, it is displaying 1373 pages of data.
Filters at Dataset Level in SSRS
Select the Dataset from the Report Data tab of the report, and Right-click on it will open the context menu. Please select the Dataset Properties.. option from it
Once we click on the Dataset Properties.. option, a new Dataset Properties window will open. Select the Filters tab.
Click on the Add button will display the below properties
- Expression: It allows you to select the available Column from the Dataset or create an Expression by clicking the fx button
- Data Type: By default, Text is selected as Datatype. Change as per the need.
- Operator: Select the operator you want to use (Like, <, <= )
- Value: Please give the value you want to check against the Expression. Please click on the fx button to write the value Expression.
In this creating SSRS Filters at Dataset Level example, We are going to display the records whose [Color] is Black. So, select the [Color] as Expression and Operator as Like and Value as Black.
Click the Ok button to finish configuring Filters at the Dataset Level in SSRS. Let us Preview the Report
If you observe the above screenshot, it displays the 224 pages of data because the remaining data is not satisfying the Filter Condition (their color is not Black).
Let us add one more SSRS Filter at the Dataset level for better understanding. Here, We are going to display the records whose [Sales Amount] is between 600 and 1000, so, Please select the [Sales Amount] as Expression and Operator as Between and Value as 600 and 1000.
Here, [Sales Amount] is the Float value. So, we have to convert both 600 and 1000 to a Decimal value. If you know the conversion function, you can directly write it. If not, click on the fx button and use the built-in functions.
TIP: If you want to delete the unnecessary filter, Please select the Filter and click on the Delete button.
Click the Ok button to finish configuring SSRS Filters at the Dataset Level. Let us Preview the Report.
If you observe the above screenshot, it is displaying the 10 pages of data because the remaining data is not satisfying the 2 Filter Conditions.