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

    Filter by selection

    Filter by selection allows choosing specific field members to display. 

    Learn more about the filter by selection:

    About the filter

    The filter by selection can be used to:

    • Include members. Only the chosen members are shown.
    • Exclude members. The members you choose are hidden.
    • Adjust the result returned by the conditional filter. Specific members can be added to the result or removed from it.

    Availability for data sources

    The filter by selection is available for all data sources.

    Note For the custom data source API, the filter by selection must be implemented on your server. For more details, refer to the Implementing filters guide.

    Applying the filter

    The filter by selection 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. Use the checkboxes to select field members that should be displayed or hidden.

    The screenshot below shows an example of a filter configuration:

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

    Note You can also use the search box to filter members.

    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, columns, or reportFilters.

    Step 2. Specify one of the following properties as an array of field members:

    • filter.members shows the members you specify.
    • filter.exclude hides the members you specify. Can be combined with the filter.query property, which represents the conditional filter.
    • filter.include shows the members you specify in addition to the members returned by the filter.query, which represents the conditional filter. filter.include must be used only together with the filter.query.

    The field members should be specified in the "<field_name>.[<field_member_name>]" format. For example:

    slice: {
      rows: [
        {
          uniqueName: "Country",
          filter: {
            members: [
              "country.[poland]",
              "country.[uk]",
              "country.[ukraine]",
            ],
          },
        },
      ]
    }

    Check out the live demo on JSFiddle.

    If the members specified in the selection filter do not exist, the filter is ignored and all field members are displayed.

    Note that the members, exclude, and include properties are incompatible with each other and must be used separately.  

    Using API calls

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

    flexmonster.setFilter("Country", {
      members: [
        "country.[poland]",
        "country.[uk]",
        "country.[ukraine]",
      ],
    });

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

    Try a live sample on JSFiddle.

    Note Filter by selection is ignored for fields with only one member.

    Clearing the filter

    Learn how to clear the filter by selection:

    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 Select all checkbox to choose all members:

    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