SpreadJS Documentation
CHOOSE
SpreadJS Documentation > Formula Reference > Formula Functions > CHOOSE

This function returns a value from a list of values.

Syntax

CHOOSE(index,value1,value2,...)

Arguments

This function has these arguments:

Argument Description
index Index of the specified values to return; an integer value between 1 and 255
value1, etc. Values from which to choose; can have up to 255 values; can be numbers, cell references, cell ranges, defined names, formulas, functions, or text

The value arguments can be range references as well as single values. For example, the formula:

   SUM(CHOOSE(2,A1:A25,B1:B10,C1:C5))

evaluates to:

   SUM(B1:B10)

which then returns a value based on the values in the range B1:B10.

Remarks

This function is evaluated first, returning the reference B1:B10. The SUM function is then evaluated using B1:B10.

Data Types

The index argument accepts numeric data. The value arguments accept any data. Returns the type of data of the specified value.

Examples

CHOOSE(3,A1,B1,C1,D1,E1) gives the result C1

CHOOSE(3,R1C1,R1C2,R1C3,R1C4,R1C5) gives the result R1C3

CHOOSE(2,"dogs","birds","fish","cats","mice") gives the result birds

See Also