Leveraging Set Analysis for in-calculation selection

By default, all calculations refer to the current selection state. In some specific situations, you may need to show data from a different selection. We can define a Set Analysis in calculations to help us modify the selection state for one or more fields.

Set Analysis is a unique feature in Qlik Sense. Each set contains a group of selected dimensional values. The sets allow the users to create independent selections, other than the one being used in the active Qlik Sense objects. The set expression is defined inside curly brackets ({}). The set identifiers are separated from the modifiers by angular brackets (< >).

A Set Analysis expression consists of three main parts:

  • Set identifiers define the relationship between the set expression and the field values or the expression that is being evaluated. Some examples include $, 1, and 1-$ - (Qlik, help).
  • Set modifiers (optional) are made up of one or several field names, each followed by a selection that should be made on the field (Qlik, help).
  • Set operators (optional) are used to refine the set of data by specifying how the sets of data represented by the identifiers or modifiers are combined to create a subset or superset of data. The most common operators are + (union), - (subtraction), and / (intersection) (Qlik, help).

For example, to summarize the sales from 2017 for two countries, we can write the following Set Analysis expression: Sum({$<OrderYear={2017},Country={Brazil, 'United Kingdom'}>}SalesAmount).

When using set modifiers, you need to specify sets of elements. The sets of elements can be enclosed in single quotation marks. Here's an explanation of single quotation marks usage:

  • For numerical elements, you don't need to use single quotation marks
  • For string elements with a single word, single quotation marks are optional
  • For string elements with two or more words, such as United Kingdom, you need to enclose them in single quotation marks
  • For date or time elements, you must enclose them in single quotation marks

You can also create a set of elements with a search expression using the same syntax used in a filter panel in your dashboard interface. In this case, it's mandatory to enclose the set using double quotation marks.

Before starting the examples, we will create a new sheet with the name Set Analysis. The following steps will help us to create and use a new sheet:

  1. Open the app and click on Create new sheet
  2. Set the title of the sheet to Set Analysis
  3. Click on the sheet icon to save the title, and then open the sheet to start creating
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset