Choose
Uses index_num to return a value from the list of value arguments. Use CHOOSE to select values based on the index number. For example, if value1 through value7 are the days of the week, CHOOSE returns one of the days when a number between 1 and 7 is used as index_num.
Syntax
CHOOSE(indexNumber, value1, [value2], ...)
The CHOOSE function syntax has the following arguments:
-
indexNumber (Required) Specifies which value argument is selected.
- If indexNumber is 1, CHOOSE returns value1; if it is 2, CHOOSE returns value2; and so on.
- If indexNumber is less than 1 or greater than the number of the last value in the list, CHOOSE returns blank.
-
Value1, value2, ... Value 1 is required, subsequent values are optional. The arguments can be numbers, field references, defined names, formulas, functions, or text.
Remarks
- The value arguments to CHOOSE can be range references as well as single values.
For example, the formula:
=SUM(CHOOSE(2,[1][1]:[1][10],[2][1]:[2][10],[3][1]:[3][10]))
evaluates to:
=SUM([2][1]:[2][10])
which then returns a value based on the values in the range [2][1]:[2][10].
The CHOOSE function is evaluated first, returning the reference [2][1]:[2][10]. The SUM function is then evaluated using [2][1]:[2][10], the result of the CHOOSE function, as its argument.
Examples
Data
Column 1 | Column 2 |
---|---|
1st | Nails |
2nd | Screws |
3rd | Nuts |
Finished | Bolts |
Formula | Description | Result |
---|---|---|
=CHOOSE(2,[Table]![1][1],[Table]![1][2],[Table]![1][3],[Table]![1][4]) | Value of the second list argument (value of column 1 row 2) | 2nd |
=CHOOSE(4,[Table]![2][1],[Table]![2][2],[Table]![2][3],[Table]![2][4]) | Value of the fourth list argument (value of column 2 row 4) | Bolts |
=CHOOSE(3,"Wide",115,"world",8) | Value of the third list argument | world |
Example 2
Data |
---|
23 |
45 |
12 |
10 |
Formula | Description | Result |
---|---|---|
=SUM([Table]![1][1]:CHOOSE(2,[Table]![1][2],[Table]![1][3],[Table]![1][4])) | Sums the range [Table]![1][1]:[1][3]. The CHOOSE function returns [Table]![1][3] as the second part of the range for the SUM function. | 80 |
Updated almost 2 years ago