Skip to main content Skip to complementary content

Set modifiers with set operators

Set operators are used to include, exclude, or intersect different element sets. They combine the different methods to define element sets.

The operators are the same as those used for set identifiers.

Operators
Operator Description
+ Union. This binary operation returns a set consisting of the records or elements that belong to any of the two set operands.
- Exclusion. This binary operation returns a set consisting of the records or elements 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 or elements that belong to both set operands.
/ Symmetric difference (XOR). This binary operation returns a set consisting of the records or elements that belong to either, but not both set operands.

For example, the following two modifiers define the same set of field values:

  • <Year = {1997, "20*"}>

  • <Year = {1997} + {"20*"}>

Both expressions select 1997 and the years that begin with 20. In other words, this is the union of the two conditions.

Set operators also allow for more complex definitions. For example:

<Year = {1997, "20*"} - {2000}>

This expression will select the same years as those above, but in addition exclude year 2000.

For more information, see Set operators.

Examples: Chart expressions for set modifiers with set operators

Examples Results
sum( {$<Product = Product + {OurProduct1} – {OurProduct2} >} Sales ) Returns the sales for the current selection, but with the product “OurProduct1” added to the list of selected products and “OurProduct2” removed from the list of selected products.
sum( {$<Year = Year + ({“20*”,1997} – {2000}) >} Sales )

Returns the sales for the current selection but with additional selections in the field “Year”: 1997 and all that begin with “20” – however, not 2000.

Note that if 2000 is included in the current selection, it will still be included after the modification.

sum( {$<Year = (Year + {“20*”,1997}) – {2000} >} Sales )

Returns almost the same as above, but here 2000 will be excluded, also if it initially is included in the current selection. The example shows the importance of sometimes using brackets to define an order of precedence.

sum( {$<Year = {“*”} – {2000}, Product = {“*bearing*”} >} Sales )

Returns the sales for the current selection but with a new selection in “Year”: all years except 2000; and only for products containing the string 'bearing'.

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!