Skip to content

Selector

aggregating category: aggregation supports `||`

Picks one of two values based on a boolean or a comparison between two values.

Selector operates in two modes — boolean and comparison.

In boolean mode, the first parameter is a boolean field reference. The second parameter is selected when the boolean is TRUE; the third (optional) parameter is selected when it is FALSE. Without a third parameter, NULL is used for the false branch.

In comparison mode, the first and third parameters are the values to compare. The second parameter is the comparison operator: <, =, >, <=, <>, or >=. The fourth parameter is selected when the comparison evaluates to TRUE; the fifth (optional) parameter is used for the false branch (defaults to NULL).

Parameters

Boolean mode

1condition Mandatory — accepts: field

A boolean field reference whose value drives the selection.

2trueValue Mandatory — accepts: field, BOOLEAN, DATE, FLOAT, INT, STRING

Value chosen when the boolean is TRUE.

3falseValue Optional — accepts: field, BOOLEAN, DATE, FLOAT, INT, STRING

Value chosen when the boolean is FALSE. Defaults to NULL when omitted.

Comparison mode

1left Mandatory — accepts: field, BOOLEAN, DATE, FLOAT, INT, STRING

First value of the comparison.

2operator Mandatory — accepts: STRING

Comparison operator. One of <, =, >, <=, <>, >=.

3right Mandatory — accepts: field, BOOLEAN, DATE, FLOAT, INT, STRING

Second value of the comparison.

4trueValue Mandatory — accepts: field, BOOLEAN, DATE, FLOAT, INT, STRING

Value chosen when the comparison is TRUE.

5falseValue Optional — accepts: field, BOOLEAN, DATE, FLOAT, INT, STRING

Value chosen when the comparison is FALSE. Defaults to NULL when omitted.

Input type

  • BOOLEAN
  • DATE
  • FLOAT
  • INT
  • STRING

Output type

The output type matches the second parameter (boolean mode) or the fourth parameter (comparison mode).

Requires

  • In comparison mode the first and the third parameter must have the same type.
  • If a third parameter (boolean mode) or fifth parameter (comparison mode) is present it must have the same type as the true-branch value.
  • In comparison mode the operator must be one of <, =, >, <=, <>, >=.

Examples

Comparison mode — equal

Selector(:int1, "=", :int2, "Equal", "Unequal")

Comparison mode — less-than with default false branch

Selector(:str1, "<", "E", :str2)

Comparison mode — not-equal dates

Selector(:date1, "<>", :date2, "Unequal dates", "Equal dates")

Comparison mode — greater-than producing string

Selector(:float1, ">", :float2, :str1)

Boolean mode

Selector(:Boolean, "True", "False")

See also

Equal, NotEqual, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, Min, Max