Skip to main content

Building a set expression

In a set expression you must always identify how the set of field values you are defining relates to the field or expression you are evaluating. For example, are you evaluating the complete set of field values or the inverse of the current selection? After you have identified this relationship you can modify the selection of values within the field (this is optional).

In short, a set expression includes an identifier and an optional modifier. Modifiers are separated from identifiers by angled brackets as follows:

{set_identifier<set_modifier>}

 

You can use operators on both identifiers and modifiers to manipulate field relationships and selections. Additionally, Qlik Sense enables you to combine modifiers with dollar-sign expansions, advanced searches and implicit field value definitions as described in the following topics.

Example:  

To understand the basics of set expression, let's look at a simple use case. We want to build a dashboard showing the following visualizations of value sales in the USA:

  1. Total value sales in the USA by product group irrespective of current selection
  2. Value sales in the USA by product group given the current selection

Our sales data is global but is divided in Region. Product groups are found in the ProductGroup field while value sales values are found in the Sales field.

In normal circumstances you could build one visualization with the dimension ProductGroup and the measure sum(Sales). User selections of Region and ProductGroup would then determine what is shown. However here we want visualization (1) above to always show the same region and selections and visualization (2) to always show the same region. Let's express what we want to see in each visualization in terms of a set expression:

  1. set_expression= {all of Sales <for RegionUSA>}
  2. set_expression= {current selection of Sales< for RegionUSA>}

Given that the:

  • qualifier for "all" is 1
  • qualifier for current selection is $
  • syntax for modifiers in this case is set_modifier = <field_name={field_value,[field_value]}

we get the following measures for our visualizations using set expressions:

  1. sum({1<Region={USA}>} Sales)
  2. sum({$<Region={USA}>} Sales)

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!