Cracking the syntax for Set Analysis

Set Analysis is a very powerful concept in Qlik Sense. In very simple terms, each set contains a group of selected dimensional values. The sets allow users to create independent selections, other than the one being used in the active Qlik Sense objects. The aggregations inside the set are compared with current selections to get the desired results.

Any set that has been created in Qlik Sense only alters the context of the expression that uses it. Unless they are referencing label names inside the same visualization, all expressions using the set syntax are independent of each other. As such, basic expressions not using Set Analysis will react to normal selections made inside the Qlik Sense document.

A Set Analysis expression consists of three main parts:

  1. Set identifiers, for example, $, 1, and 1-$
  2. Set operators
  3. Set modifiers (optional)

A set expression is defined inside curly brackets {}. Set identifiers are separated from modifiers by angular (<>) brackets.

Set identifiers define the relationship between the set expression and the field values or the expression that is being evaluated (Qlik, help).

The set modifier is made up of one or several field names, each followed by a selection that should be made in the field (Qlik, help).

For example, to compare sales from the current year against last year's sales for three countries, we can write the following Set Analysis expression:

Sum({$<Year={2014,2015},Country={USA, 'UNITED KINGDOM', GERMANY}>}Sales) 

When using set modifiers, you need to specify sets of elements. They can be enclosed by single quotes or not. The following is an explanation regarding single quote usage:

  • For numerical elements, you don't need to use single quotes
  • For string elements with a single word, single quotes are optional
  • String elements with two or more words, such as 'United Kingdom,' need to be enclosed  it by single quotes
  • Date and time elements need to be enclosed by single quotes as well

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

You will learn more about these rules in the following recipes.

..................Content has been hidden....................

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