Need a special offer?Find out if your project fits.
+
All documentation
  • Introduction
  • Connecting to Data Source
  • Browser compatibility
  • Documentation for older versions
  • Advanced tips

    In this guide, you can learn about advanced filtering options.

    Combine the conditional and selection filters

    Conditional and selection filters can be combined only programmatically, not via UI.

    To combine the filters, follow the steps below:

    Step 1. Specify the conditional filter for the necessary field using the filter.query.

    Step 2. For the same field, specify the selection filter using one of the following properties:

    • filter.include – adds the specified members to the results of the conditional filter.
    • filter.exclude – removes the specified members from the results of the conditional filter.

    Step 3. Preset the filter combination in the report or apply it using the setFilter() API call to see the result:

    In the report

    rows: [
      {
        uniqueName: "Country",
        filter: {
          query: {
            // Include countries with "United" in their name
            contain: "United" 
          },
          // Include countries listed below
          include: [
            "Country.[France]", 
            "Country.[Germany]",
          ]
        },
      },
    ],

    See the full code on JSFiddle.

    Using API call

    const combinedFilter = {
      query: {
        // Include countries with "United" in their name
        contain: "United" 
      },
      // Include countries listed below
      include: [
        "Country.[France]", 
        "Country.[Germany]",
      ]
    };
     
    flexmonster.setFilter("Country", combinedFilter);

    Note If there is a filter combination in the slice, we recommend disabling the filter view since it does not support filter combinations. The filter view can be disabled:

    Show an empty grid when filtering by non-existent members

    By default, if the selection filter contains only non-existent members, Flexmonster ignores it and displays all field members.

    If you want to change this behavior so that an empty grid is shown instead, follow the steps below:

    Step 1. Specify the required field members in the filter.include property. Here is an example:

    rows: [
      {
        uniqueName: "Category",
        filter:{
          // Selection filter
          // Members that might not exist in the report
          include: ["Computers", "Phones"]  
        },
      },
    ],

    Step 2. For the same field, specify the filter.query property that always returns an empty result. In the example below, the equal: "" query returns an empty result because there are no blank field members in our dataset:

    rows: [
      {
        uniqueName: "Category",
        filter:{
          // Selection filter
          // Members that might not exist in the report
          include: ["Computers", "Phones"],
          // Conditional filter
          // The query always returns an empty result
          query: { equal: "" }
        },
      },
    ],

    Now the filter.query will cover the cases when the filter.include is ignored. Since the filter.query always returns an empty result, an empty grid will be shown if you specify non-existent members in the filter.include. See the full code on JSFiddle.

    Learn more about combining the conditional and selection filters.

    The search in the filter pop-up window can be used to select or deselect multiple members at once.

    Use the search depending on how you want to modify the selection filter:

    Select a group of members

    Step 1. Open the filter pop-up window.

    Step 2. optional To clear the current selection, click Select all until all members are deselected.

    Step 3. In the search box, enter a search term to find the members you want to include. For example, to include Poland and Switzerland in the selection, enter land in the search box.

    Step 4. Click Select all results until all members that match the search term are selected. If there are members you want to exclude, deselect them individually.

    Step 5. optional To include more members, click × in the search box and return to Step 2.

    Step 6. Click Apply to see the result.

    Deselect a group of members

    Step 1. Open the filter pop-up window.

    Step 2. optional To clear the current selection, click Select all until all members are selected.

    Step 3. In the search box, enter a search term to find the members you want to exclude. For example, to exclude Poland and Switzerland from the selection, enter land in the search box.

    Step 4. Click Select all results until all members that match the search term are deselected. If there are members you want to include, select them individually.

    Step 5. optional To exclude more members, click × in the search box and return to Step 2.

    Step 6. Click Apply to see the result.

    See also