Set modifiers
A set can be modified by an additional or a changed selection. Such a modification can be written in the set expression.
The modifier consists of one or several field names, each followed by a selection that should be made on the field, all enclosed by angled brackets: < >. For example: <Year={2007,2008},Region={US}>. Field names and field values can be quoted as usual, for example: <[Sales Region]={'West coast', 'South America'}>.
A set modifier modifies the selection of the preceding set identifier. If no set identifier is referenced, the current selection state is implicit.
There are several ways to define the selection:
- Based on another field
- Based on element sets (a field value list in the modifier)
- Forced exclusion
These methods are described in the following subsections.
Based on another field
A simple case is a selection based on the selected values of another field, for example <OrderDate = DeliveryDate>. This modifier will take the selected values from DeliveryDate and apply those as a selection on OrderDate. If there are many distinct values – more than a couple of hundred – then this operation is CPU intensive and should be avoided.
Based on element sets
The most common example of a set expression is one that is based on a list of field values enclosed in curly brackets. The values are separated by commas, for example
Unless the listed values contain blanks or special characters, quotes are not needed. The listed values will simply be matched with the field values. This comparison is case insensitive.
If the listed values contain blanks or special characters, or if you want to use wild cards, then you need to enclose the values in quotation marks. Single quotes should be used if the listed values are explicit field values. Then case sensitive matches between the listed values and the individual field values will be made.
Double quotes should be used for searches, i.e. strings that contain wild cards or start with a relational operator or an equals sign. For example,
In previous versions of Qlik Sense, there was no distinction between single quotes and double quotes and all quoted strings were treated as searches. To maintain backward compatibility, apps created with older versions of Qlik Sense will continue to work as they did in previous versions. Apps created with Qlik Sense November 2017 or later will respect the difference between the two types of quotes.
Forced exclusion
Finally, for fields in AND-mode, there is also the possibility of forced exclusion. If you want to force exclusion of specific field values, you will need to use “~” in front of the field name.
Examples and results:
Examples | Results |
---|---|
|
Returns the sales for the region |
|
Returns the sales for the current selection, but with the selection in ' |
|
Returns the same as the example immediately above. When the set to modify is omitted, $ is assumed. Note: The syntax in the two previous examples is interpreted as “no selections” in '
|
|
Returns the sales for current selection, but with new selections both in ' |
|
The field Ingredient is in AND mode. Returns the sales for current selection, but with a forced exclusion of all ingredients containing the string 'garlic'. |
|
Returns the sales for the current selection, but with all years beginning with the digit “2”, i.e. most likely year 2000 and onwards, selected in the field ' |
|
As above, but now also the 1980:s are included in the selection. |
|
Returns the sales for the current selections, but with a numeric search used to scope the range of years to sum the sales across. |