[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Collapse]Reporting
 [Expand]Product Information
 [Expand]Getting Started with DevExpress Reporting
 [Expand]Creating Popular Reports
 [Collapse]Detailed Guide to DevExpress Reporting
   Introduction to Banded Reports
  [Expand]Providing Data to Reports
  [Expand]Using Report Controls
  [Collapse]Shaping Report Data
   [Collapse]Data Filtering
     Data Filtering Overview
     Filtering Data at the Report Level
     Filtering Data at the Data Source Level
     Filtering Data at the Data Source Level (Runtime Sample)
   [Expand]Grouping and Sorting
   [Expand]Shaping Data using Expression Bindings
   [Expand]Shaping Data using Legacy Data Bindings
   [Expand]Using Calculated Fields
   [Expand]Using Report Parameters
   Laying out Dynamic Report Contents
  [Expand]Customizing Appearance
  [Expand]Adding Navigation
  [Expand]Providing Interactivity
  [Expand]Adding Customary Information
  [Expand]Merging Reports
  [Expand]Using Expressions
  [Expand]Storing and Distributing Reports
  [Expand]Reporting API
 [Expand]Visual Studio Report Designer
 [Expand]Creating End-User Reporting Applications
 [Expand]API Reference
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
This documentation page describes implementations made in our v17.2 release cycle. To learn about functionality shipping with v18.1, navigate to our updated help file experience at docs.devexpress.com. Learn More

Data Filtering Overview

  • Filter a SQL Data Source
    Filter records at data source level using your data connection query if you are binding to a large data source and want to speed up the retrieval process.

  • Filter Data Using Report's Settings
    Use the report's settings demonstrated in this section if you want to load the entire dataset and filter it on the client.

  • Limit the Number of Records to Display
    Options described in this section allow you to emulate the Top N feature in a sorted report or increase the Print Preview performance by rendering only a subset of a report’s data.

  • Conditionally Change Element Visibility
    Use this technique to hide certain report elements from the Detail band when the corresponding data records meet the specified criteria.

Expanded Filter a SQL Data Source

You can filter data records before supplying them to a report when you create a new data-bound report or bind an existing one to a SqlDataSource.

You can also apply filtering in an existing data source by right-clicking it in the Report Explorer or Field List and selecting Manage Queries. In the Manage Queries window, click the required query's ellipsis button.

In the invoked Query Editor, click the Run Query Builder button and use the Query Builder to specify the filter criteria as shown in the following image:

The filter string can reference query parameters that you can link to report parameters.

See Filtering Data at the Data Source Level for detailed instructions on using query parameters.

Expanded Filter Data Using Report's Settings

Use the report's XtraReportBase.FilterString property to filter records at the report level. Locate this property using the report's smart tag and click the corresponding ellipsis button to invoke the Filter Editor.

You can filter detail report data individually in a master-detail report.

In the invoked Filter String Editor, specify filter criteria that can reference report parameters and calculated fields.

Refer to Filtering Data at the Report Level for a step-by-step tutorial. See Creating Criteria to learn more about filter criteria syntax.

Expanded Limit the Number of Records to Display

You can filter records displayed in Print Preview using the ReportPrintOptions class.

  • Limiting the Number of Records

    Use the ReportPrintOptions.DetailCount option to define how many times to print the Detail band in Print Preview at runtime (similar to the TOP clause in SQL).

    The ReportPrintOptions.DetailCountAtDesignTime property enables you to limit the number of records a report shows at design time in Visual Studio. Click the report's smart tag to access this setting as shown in the image below.

  • Printing on Empty Data Source

    Disable the ReportPrintOptions.PrintOnEmptyDataSource option to avoid generating a report when its data source is empty. You can use this setting in master-detail reports to hide the detail report if its data source contains no records.

    The ReportPrintOptions.DetailCountOnEmptyDataSource property allows you to specify how many times to print the Detail band when a report does not have a data source. You can use this property to create static reports that are not connected to a data source and display the same static content several times.

Expanded Conditionally Change Element Visibility

You can show or hide a specific report control in Print Preview based on a logical condition. For instance, the following example illustrates a document that displays the State field only if the Country value is "USA".

Select the target label on the report's surface, switch to the Property Grid's Expressions tab and click the XRControl.Visible property's ellipsis button.

In the invoked Expression Editor, specify the expression that defines when a control should be visible.

Add these controls to the Panel and set its XRControl.CanShrink property to true which automatically adjusts the panel's size to fit all the controls and prevent blank areas.

Note

You can conditionally change control visibility using formatting rules if your report uses the legacy binding mode (the UserDesignerOptions.DataBindingMode is set to DataBindingMode.Bindings).

Is this topic helpful?​​​​​​​