Skip to end of metadata
Go to start of metadata

This is a compilation of tips, tricks, and workarounds sourced by the Qlik Developer Community for developing content in Qlik Sense. Content in this guide will expand as items are encountered.  

Table of Contents


How to Filter at the Object Level

Author: Melissa Chan
Last edited: 11/9/20


By default, Qlik filters all objects on all sheets at the same time. There is no built-in functionality to filter just one object (graph/chart/table) and not all other data in the app. This provides a workaround for creating a filter on just one object by using the Variable Input Extension. 

Options that Do Not Meet this Need:  

  • Filtering the Where clause of the script editor filters all sheets, not just one.
  • A default bookmark filters all sheets, not just one. Plus, the user needs to create the bookmark and set it as their default in order for this option to work.
  • Alternate States requires the user to make the selection. It is not pre-defined by the developer. 

Solution Overview

Using Variable Input Control (a built-in Qlik extension) meets all the needs listed above. Variable Input Control is typically used to compare outcomes based on user-selected data. For example, a user can estimate how much sales (outcome) will increase by selecting varying levels of discounts (variable), where a 75% discount would generate more sales than a 5% discount.  A variable can be a calculation itself or a predetermined value. A variable that is simply equal to a field (with no calculation applied) acts like a filter.

To meet our needs, we will use this extension in a slightly different manner than intended. A high level overview of the steps involved are as follows, where the Developer will:

  1.  Create a variable
  2.  Add and format the Variable Input Control extension
  3.  Tie the Variable Input Control to the desired object

Step-by-Step Guide

Follow along in the Qlik app Filter at the Object Level using Variable Input Control. Make a copy and open it in your Workspace to practice. In this example I created a variable that allows the user to filter Region on some objects but not all. See Qlik's page on Variable Input Control for more details.

  1.  Create a variable 
    Qlik's How to Create a Variable explains what a variable is and also provides instructions on how to create one. 
    1. In upper right, click Edit
    2. In lower left, click Variables 
    3. Click Create New
      1. Give the variable a Name starting with the letter 'v' or 'var' to distinguish from fields and functions. See Qlik's How to Create a Variable for more naming conventions.
      2. Under Definition, click fx and input the Field you want to filter on. 
        1. For example set the Definition as the field:  Region
          Be sure to click on the orange fx to enter a field. Do not simply type it in the box as Qlik may not register it.
        2. If you want the input box to display instructions, simply type that text under Definition without clicking on fx. Example: Enter selection here
          This displays in the box where the user can make selections.
      3. Description and tags are optional
      4. Click the pencil icon to save, then click Close.
      5. You've successfully created a variable! 
        Note: there are other ways of creating variables (such as in the script editor) and you can create multiple variables. 

  2.  Create the Variable Input Control. Read Qlik's How to Create a Variable Input Control for more details.
    1.  With the sheet still in Edit mode, Go to Custom Objects > Qlik Dashboard bundle and drag Variable Input onto the sheet.
    2.  Under General, type in a Title or select to not display the title.
    3.  Under Variable > Name, select the variable you created (in this case vRegion)
       Keep it set to 'Input box' for now. I've found that order of operations matters and this works best when starting with the Input Box design.  You can change it later.
    4.  You've successfully created a Variable Input Control! 
       Note: At this point, your Variable Input box is simply that - a box. It currently has no impact on the app because it does not contain any values and is not tied to any object. 
       We will fix that in the next steps.

  3.  Add a value to the Variable Input box. These must match existing values for the underlying field.
    1.  In upper right, click Done to exit edit mode.
    2.  In the input box, erase the existing text and type in a value that belongs to the field you want to filter on. It must match an existing value for that field. Example: Spain
    3. You've successfully added 1 or more values to your Variable Input Control!
      Note:  The flow works most successfully by adding just one value to complete the set up. Once those steps are done, we will go back in to add add additional values.

  4.  Tie the Variable Input to the desired object(s)
    1. In the upper right click Edit, then select the object you want to apply the Variable to.
    2. Edit a dimension to display only if the value that the user selects matches that same value of the field. For example: 
         Before:  Region
         After:    =If('$(vRegion)'=Region,Region)
                      The $ indicates the users selection. Since Region is a text field, the apostrophes changes the users value to text to match the field. 
                      In this case, we entered Spain as the value. Therefore, only the Sum of Sales for Spain will now display.
         Tip:       Notice that the value you input appears in the footer of the Expression Editor.
                      If the formula isn't working, troubleshoot by removing apostrophes, changing the input value, and adding back the apostrophes until it works.
    3. Uncheck the box if you want to hide null values
    4. Check that the amount matches the control group in the top half of the sheet.
    5. Repeat for any other desired objects

  5. Optional: Change the input style
    We intentionally used the Text Input box to start because I encountered errors when starting with, say, the Drop Down. Now that the Variable Input extension is working, we can switch styles if desired.
    1. In the upper right click Edit
    2. Select the Variable Input box to activate it
    3. On the right, click on Appearance > Variable
    4. Under Show as, select the desired option
    5. For Dropdown:
      1. For the Fixed dropdown
        1. Select Fixed values to type in each desired dropdown option
        2. Click Add Alternative
        3. Type one of the values both in the Value box and Label box. Be sure it is spelled exactly as one of the field's existing values.
        4. Repeat until all your desired values are included. Values appear in the order in which you add them.
      2. For the Dynamic dropdown
        1. Use a formula like the following to get all values to appear without manually entering them
                =Concat(Distinct Region,'|')
          Note:  I have not found a way to rearrange the order the values are displayed with Dynamic dropdown. This formula does not support including Desc and using Order By after the Resident Table in the Script Editor does not work either.
    6. The Button option works similarly to Dropdown. 
    7. Note: the Slider only works for numerical values

Congratulations! You learned how to create a Variable Input Control that acts as a filter at the object level. Try practicing this yourself using the 2nd sheet of this example app:
Filter at the Object Level using Variable Input Control

Related Links: