Conditionally Filter Report Data
- 2 minutes to read
This tutorial demonstrates how to filter a report's data based on a certain condition.
See Conditionally Filter Report Data to learn about the alternative approach to solving this task.
See Data Binding Modes to learn more about the available binding modes.
The report created in this tutorial displays products having the price exceeding $50:
Do the following to conditionally filter report data:
- To create a table report in this tutorial, start with a report that is bound to the "Products" table of the sample Northwind database (the nwind.mdb file included in the XtraReports installation). To learn more about binding a report to a data source, see Provide Data to Reports.
Then, in the invoked Formatting Rules Editor, click the Edit Rule Sheet... button.
In the invoked Formatting Rule Sheet Editor, click , to create a new formatting rule. For this rule, set the Visible property to false.
Next, locate the FormattingRule.Condition property and click its ellipsis button. The Condition Editor will appear.
In this editor, define a Boolean expression for the rule (e.g., [UnitPrice] <= 50). The [UnitPrice] <= 50 expression means that the UnitPrice data field should be less than or equal to 50 for the appropriate data row to be hidden.
Click OK to save the changes and close the dialog. Then click Close to quit the Formatting Rule Sheet Editor.
In the Formatting Rules Editor, you can see the created rule (called formattingRule1), which should be moved to the list of active rules on the right using the arrow buttons in the center of the dialog box.
In this editor, you can also customize the precedence of formatting rules using the up and down arrow buttons on the right of the dialog box. The rules are applied in the same order that they appear in the list, and the last rule in the list has the highest priority.