How do you use the CHOOSE function to return values based on an index?
Posted by MaryJns
Last Updated: July 14, 2024
The CHOOSE function in Excel is a versatile tool that allows you to return a value from a list based on a given index number. The syntax for the CHOOSE function is as follows:
=CHOOSE(index_num, value1, [value2], ...)
- index_num: This is a required argument that specifies which value to return. It must be a positive integer (1, 2, 3, ...). - value1, value2, ...: These are the values from which CHOOSE will return the result. You can specify up to 254 values.
Example Usage
1. Basic Example: Suppose you want to choose a specific fruit based on an index.
=CHOOSE(2, "Apple", "Banana", "Cherry", "Date")
- In this example, the function will return "Banana" because it is the second item in the list. 2. Dynamic Index: You can also use a cell reference for the index number. Suppose cell A1 contains the number 3:
=CHOOSE(A1, "Red", "Green", "Blue", "Yellow")
- If A1 is 3, this formula will return "Blue" since it is the third item in the list. 3. Using CHOOSE with Other Functions: You can use CHOOSE in combination with other functions. For example, retrieve a value based on a condition:
=CHOOSE(IF(B1="Small", 1, IF(B1="Medium", 2, 3)), "S", "M", "L")
- If B1 is "Medium", this formula will return "M".
Things to Keep in Mind
- If the index_num is less than 1 or greater than the number of values provided, CHOOSE will return a #VALUE! error. - You can combine CHOOSE with functions like MATCH, IF, or VLOOKUP to create more complex formulas based on dynamic inputs. The CHOOSE function is great for scenarios where you want to conditionally select from a predefined list of values based on an index, giving you flexibility and efficiency in your data handling in Excel.
Related Content