In SQL Server Reporting Services, Filters are similar to SQL WHERE Clause. SSRS Dataset level Filters are used to restrict the Records displayed by the Reports. In this article, we will show you the steps involved to apply filters at Dataset Level in SSRS (SQL Server Reporting Services) with an example.
SSRS supports two types of Filters: Filters at Tablix Level and Filters at Dataset Level.
TIP: 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 WHERE Clause article.
We use the below-shown report to explain, SSRS filtering the data at 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 the 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 to select the available Column from the Dataset, or create an Expression by clicking the fx button
- Data Type: By default, Text 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 value Expression.
In this 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 Dataset Level in SSRS. Let us Preview the Report
If you observe the above screenshot, it is displaying 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 Filter at 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 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 Filters at 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.