Skip to main content

Set operators

There are several set operators that can be used in set expressions. All set operators use sets as operands and return a set as result.

The order of precedence is:

  1. Unary minus (complement)
  2. Intersection and Symmetric difference

  3. Union and Exclusion.

Within a group, the expression is evaluated from left to right. Alternative orders can be defined by standard brackets, which may be necessary because the set operators do not commute. For example, A+(B-C) is different from (A+B)-C which in turn is different from (A-C)+B.

Warning noteThe use of set operators in combination with basic aggregation expressions involving fields from multiple Qlik Sense tables may cause unpredictable results and should be avoided. E.g. if Quantity and Price are fields from different tables, then the expression sum({$*BM01}Quantity*Price) should be avoided.

Arguments:  

Operator Description
+ Union. This binary operation returns a set consisting of the records that belong to any of the two set operands.
- Exclusion. This binary operation returns a set of the records that belong to the first but not the other of the two set operands. Also, when used as a unary operator, it returns the complement set.
* Intersection. This binary operation returns a set consisting of the records that belong to both of the two set operands.
/ Symmetric difference (XOR). This binary operation returns a set consisting of the records that belong to either, but not both of the two set operands.

Examples and results:  

Examples Results
sum( {1-$} Sales ) Returns sales for everything excluded by the current selection
sum( {$*BM01} Sales ) Returns sales for the intersection between the current selection and bookmark BM01
sum( {-($+BM01)} Sales )

Returns sales excluded by current selection and bookmark BM01

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!