Skip to main content

Set modifiers

Set expressions are used to define the scope of a calculation. The central part of the set expression is the set modifier that specifies a selection. This is used to modify the user selection, or the selection in the set identifier, and the result defines a new scope for the calculation.

The set modifier consists of one or more field names, each followed by a selection that should be made on the field. The modifier is enclosed by angled brackets: < >

For example:

  • Sum ( {$<Year = {2015}>} Sales )

  • Count ( {1<Country = {Germany}>} distinct OrderID )

  • Sum ( {$<Year = {2015}, Country = {Germany}>} Sales )

Element sets

An element set can be defined using the following:

  • A list of values

  • A search

  • A reference to another field

  • A set function

If the element set definition is omitted, the set modifier will clear any selection in this field. For example:

Sum( {$<Year = >} Sales )

Examples: Chart expressions for set modifiers based on element sets

Listed values

The most common example of an element set is one that is based on a list of field values enclosed in curly brackets. For example:

  • {$<Country = {Canada, Germany, Singapore}>}

  • {$<Year = {2015, 2016}>}

The inner curly brackets define the element set. The individual values are separated by commas.

Quotes and case sensitivity

If the values contain blanks or special characters, the values need to be quoted. Single quotes will be a literal, case-sensitive match with a single field value. Double quotes imply a case-insensitive match with one or several field values. For example:

  • <Country = {'New Zealand'}>

    Matches New Zealand only.

  • <Country = {"New Zealand"}>

    Matches New Zealand, NEW ZEALAND, and new zealand.

Dates must be enclosed in quotes and use the date format of the field in question. For example:

  • <ISO_Date = {'2021-12-31'}>

  • <US_Date = {'12/31/2021'}>

  • <UK_Date = {'31/12/2021'}>

Double quotes can be substituted by square brackets or by grave accents.

Searches

Element sets can also be created through searches. For example:

  • <Country = {"C*"}>

  • <Ingredient = {"*garlic*"}>

  • <Year = {">2015"}>

  • <Date = {">12/31/2015"}>

Wildcards can be used in a text searches: An asterisk (*) represents any number of characters, and a question mark (?) represents a single character. Relational operators can be used to define numeric searches.

You should always use double quotes for searches. Searches are case-insensitive.

For more information, see Set modifiers with searches.

Dollar expansions

Dollar expansions are needed if you want to use a calculation inside your element set. For example, if you want to look at the last possible year only, you can use:

<Year = {$(=Max(Year))}>

For more information, see Set modifiers with dollar-sign expansions.

Selected values in other fields

Modifiers can be 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.

Element set functions

The element set can also be based on the set functions P() (possible values) and E() (excluded values).

For example, if you want to select countries where the product Cap has been sold, you can use:

<Country = P({1<Product={Cap}>} Country)>

Similarly, if you want to pick out the countries where the product Cap has not been sold, you can use:

<Country = E({1<Product={Cap}>} Country)>

For more information, see Set modifiers using set functions .