Skip to main content
A newer version of this page is available. .

Filtering

  • 3 minutes to read

You can filter Extract Data Source data in the Dashboard Designer or in code.

Use Dashboard Designer to Apply a Filter

To apply a filter to a data source, click the Filter button in the Data Source Ribbon tab.

DataSourceFiltering_FilterButton_Ribbon

This invokes the Filter Editor dialog that allows you to build filter criteria:

DataSourceFiltering_FilterEditor

Tip

Documentation: Filter Editor

To clear the data source filter, use the Clear Filter button in the Data Source Ribbon tab.

Pass Parameter Values

You can use the Filter Editor to filter a data source according to the current parameter value. See the Pass Parameter Values topic for details.

Specify a Filter Criteria in Code

To specify the filter criteria in code, use the DashboardExtractDataSource.Filter property. Review the Expression Constants, Operators, and Functions topic for more information.

Example

The following example demonstrates how to create a new dashboard parameter and pass it to a dashboard item filter string.

In this example, the dashboard data source contains two queries - the SalesPerson query is used for data visualization while the Categories query provides values for the dashboard parameter.

After the dashboard parameter is created, it is passed to a dashboard item’s filter strings. So, the dashboard displays data according to the selected values.

View Example

using DevExpress.XtraEditors;
using DevExpress.DashboardCommon;

namespace Dashboard_Parameters {
    public partial class Form1 : XtraForm {
        public Form1() {
            InitializeComponent();
            Dashboard dashboard = new Dashboard();
            dashboard.LoadFromXml(@"..\..\Data\Dashboard.xml");

            // Obtain dashboard items and specify identifiers for data items.
            GridDashboardItem grid = (GridDashboardItem)dashboard.Items[0];
            PieDashboardItem pie = (PieDashboardItem)dashboard.Items[1];  
            ((GridDimensionColumn)grid.Columns[0]).Dimension.UniqueId = "categoryColumn";
            pie.SeriesDimensions[0].UniqueId = "categorySeries";

            // Obtain the dashboard data source used to provide parameter values.
            DashboardSqlDataSource parameterDataSource = 
                (DashboardSqlDataSource)dashboard.DataSources[0];

            // Create a new parameter that obtains its values from the Categories query.
            DynamicListLookUpSettings settings = new DynamicListLookUpSettings();
            settings.DataSource = parameterDataSource;
            settings.DataMember = "Categories";
            settings.ValueMember = "CategoryName";
            DashboardParameter parameter = new DashboardParameter("categoryParameter", 
                typeof(string), "Beverages", "Select categories:", true, settings);
            // Enable multi-selection for the created parameter.
            parameter.AllowMultiselect = true;

            // Add the created parameter to a collection of dashboard parameters.
            dashboard.Parameters.Add(parameter);

            // Include the created parameter in filter strings as an operand value.
            grid.FilterString = "categoryColumn in (?categoryParameter)";
            pie.FilterString = "categorySeries in (?categoryParameter)";

            dashboardViewer1.Dashboard = dashboard;
        }
    }
}