1. API reference
Connecting to Data Source
Configuring the component
  • Documentation for older versions
  • Table of contents

    Filter by value

    Filter by value allows filtering records based on values of a certain measure. For instance, you can show the top 3 products with the highest sales or revenue.

    Learn more about the filter by value:

    About the filter

    Filter by value consists of a measure to filter by, a condition applied to the measure, and values for the condition. Here is an example of a value filter, where Sum of Price is a measure to filter by, Top is a filtering condition, and 5 is a condition value:

    Value filter can be applied only to fields in rows and columns, not in report filters. This filter is also incompatible with the conditional and selection filters.

    Availability for data sources

    The filter by value is available for the following data sources:

    Available conditions

    The following filtering conditions can be applied to a measure:

    • Top – Shows X members with the greatest values, where X is a number you specify.
    • Bottom – Shows X members with the lowest values, where X is a number you specify. 
    • Equal – Shows members with values equal to the specified value.
    • Not equal – Shows members with values not equal to the specified value.
    • Greater – Shows members with values greater than the specified value.
    • Greater or equal – Shows members with values greater than or equal to the specified value.
    • Less – Shows members with values less than the specified value.
    • Less or equal – Shows members with values less than or equal to the specified value.
    • Between – Shows members with values between two values (including them).
    • Not between – Shows members with values not between two values (excluding them).

    Applying the filter

    The filter by value can be:

    • Applied via UI.
    • Preset in the report.
    • Applied using API calls.

    Note If you want to preset a filter in your report, we recommend the following approach:

    1. Configure the filter via UI.
    2. Save the report
    3. Open the saved report and copy the filter configuration into the report used in your project.

    Via UI

    Step 1. Open the filter view by clicking the field’s name or using the field’s context menu.

    Step 2. Select the VALUES filtering option. This will open a subview where you can specify the filter by value.

    Step 3. In the subview, choose a measure to filter by from the dropdown menu. Then, choose a filtering condition and enter a value for it.

    The screenshot below shows an example of a filter configuration:

    Step 4. Once the filter is configured, click the APPLY button to save your configuration.

    In the report

    Step 1. In the slice, add the filter property to the field you want to filter. The field can be from the rows or columns.

    Step 2. Specify the filter.query property. A list of available conditions for this property is described in the ValueQueryObject

    Step 3. Specify a measure to filter by in the filter.measure property. The measure must be defined in the slice. Calculated measures can be used as well.

    Here is an example of how the filter can be defined:

    slice: {
      rows: [
        {
          uniqueName: "Country",
          filter: {
            measure: {
              uniqueName: "Price",
              aggregation: "sum",
            },
            query: {
              top: 5,
            },
          },
        },
      ]
    }

    Check out the live demo on JSFiddle.

    Note Filter by value can contain only one condition at a time.

    Using API calls

    To set or change the filter at runtime, use the setFilter() API call:

    flexmonster.setFilter("Country", {
      measure: {
        uniqueName: "Price",
        aggregation: "sum",
      },
      query: {
        top: 5,
      },
    });

    You can view the existing filter configuration using the getFilter() method.

    Try a live sample on JSFiddle.

    Note Filter by value can contain only one condition at a time.

    Clearing the filter

    Learn how to clear the filter by value:

    Via UI

    Step 1. Open the filter view by clicking the field’s name or using the field’s context menu.

    Step 2. Select the Clear value filter option located in the lower-right corner of the subview:

    Step 3. Click the APPLY button to save your changes.

    Using API calls

    You can clear all filters from a field using the clearFilter() API call. For example:

    flexmonster.clearFilter("Country");

    Try a live sample on JSFiddle.

    See also