Skip to content
HPCCSystems Solutions Lab
HPCCSystems Solutions Lab

CHOOSE

CHOOSE function eEvaluates the expression and returns the value parameter whose ordinal position in the list of parameters corresponds to the result of the expression. All values for this function must have the same type . If no match is found it will return the else-value.

Example


/*
CHOOSE Example:
*/

Eval := 4;

CHOOSE(Eval, 2, 3, 5, 6, 20);      // Returns 6

CHOOSE(Eval, 6, 6, 7, 10, 9, 11);  // Returns 10

CHOOSE(Eval, 3, 4, 8);             // Returns 8 (the else value)
Try Me

Syntax

CHOOSE(Expression, Value1,... , ValueN, Else);
ValueDefinition
ExpressionEvaluation field
Value1 … ValueNIf expression matches it will return the result
ElseIf nothing matches else-value is returned

Example


/*
CHOOSE Example:
*/

CHOOSE(2, 3, 5, 6, 20);          // Returns 5

CHOOSE(3, 'foo', 'bar', 'baz');  // Returns 'baz'

getVal := CHOOSE(5, 'foo', 'bar', 'baz');  // Returns 'baz' (the else value)

OUTPUT(getVal, NAMED('getVal'));
Try Me