FlexPivot for WPF | ComponentOne
Data Blending / Filtering / Range Filter
In This Topic
    Range Filter
    In This Topic

    FlexPivot allows you to filter and display data in a specified range. When you apply the range filter, it allows you to filter data based on some condition(s). For example, let's say a company wants to view sales of their products in different countries for the complete year 2014. For this, they needs to slice the Country field in the database using range filters as shown in the following image.

    The image given below shows a FlexPivotGrid displaying the sales of all the products ordered in the year 2014.

    Applied RangeFilter on the data in FlexPivot

    Apply Range Filter at Runtime

    Complete the following steps to implement range filtering in the FlexPivotGrid control. This implementation uses the sample created in Quick Start topic.

    1. Add OrderDate field in the Rows list.
    2. Right-click the OrderDate field in the Rows list and click Field Settings option once to open the Field Settings dialog.
    3. Click the Date/Time Filter once and then click Custom Filter to apply conditions. This opens the Custom Filter dialog.
    4. Set the condition "Greater Than or Equal to" and "Less than or Equal to" to "01-01-2014 00:00:00" and "31-12-2014 00:00:00" respectively in the Custom Filter dialog as illustrated below.

      Custom Filter dialog

    5. Click OK to see that the FlexPivotGrid control displays relevant data.

    Apply Value Filter Programmatically

    To apply the range filter programmatically for the above discussed scenario using the C1FlexPivotFilter class, use the following code:

    C#
    Copy Code
    //Apply range filter to show only some dates
    C1.FlexPivot.C1FlexPivotFilter rangefilter = fpEngine.Fields["OrderDate"].Filter;
    rangefilter.Clear();
    rangefilter.Condition1.Operator = C1.FlexPivot.ConditionOperator.GreaterThanOrEqualTo;
    rangefilter.Condition1.Parameter = new DateTime(2014, 1, 1);
    rangefilter.Condition2.Operator = C1.FlexPivot.ConditionOperator.LessThanOrEqualTo;
    rangefilter.Condition2.Parameter = new DateTime(2014, 12, 31);
    rangefilter.AndConditions = true;