Investment Studio > Expressions > Functions > Reference > CHOOSE
choose (integer argument_index, argument [, ...])
Returns the indexed argument: argument_index = 1 returns the first argument, argument_index = 2 returns the second argument and so on.
Arguments may be arrays, in which case each array counts as a single indexed entry.
| To build an error-tolerant CHOOSE expression, compute the value of each possible result separately, assign the results to symbols, then use the symbols in the CHOOSE expression. |
This way, errors occurring during result evaluation will not prevent the CHOOSE expression from being evaluated. This is different from evaluating the results and CHOOSE in the same expression because expression evaluation is aborted when it results in an error; if the results are evaluated in the same expression as CHOOSE, an error occurring during the evaluation of any element in the result list will prevent the entire CHOOSE expression from being evaluated.
Computation of the argument_index can also be made error-tolerant using the OR operator.
Examples
=choose(3, "1st", "2nd", "3rd", "4th")
returns "3rd"
=A1:choose(2, A10, A20, A30)
returns the range reference A1:A20
=choose(2, {1, 2, 3}, {{1, 2}, {3, 4}}, 10)
returns the array {{1, 2}, {3, 4}}.