Skip to main content


CHOOSE(expression, value,... , value, elsevalue)

expressionAn arithmetic expression that results in a positive integer and determines which value parameter to return.
valueThe values to return. There may be as many value parameters as necessary to specify all the expected values of the expression. This may be any expression or action.
elsevalueThe value to return when the expression returns an out-of-range value. The last parameter is always the elsevalue.
Return:CHOOSE returns a single value.

The CHOOSE function evaluates the expression and returns the value parameter whose ordinal position in the list of parameters corresponds to the result of the expression. If none match, it returns the elsevalue. All values and the elsevalue must be of the same type.


MyExp := 1+2;
MyChoice := CHOOSE(MyExp,9,8,7,6,5); // returns 7
MyChoice := CHOOSE(MyExp,1,2,3,4,5);  // returns 3
MyChoice := CHOOSE(MyExp,15,14,13,12,11);  // returns 13
WorstRate := CHOOSE(IntRate,1,2,3,4,5,6,6,6,6,0);
 // WorstRate receives 6 if the IntRate is 7, 8, or 9

See Also: CASE, IF, MAP