ExcelTool.io

SWITCH and CHOOSE Generator

Match a value against a list of cases with SWITCH and add a default, plus how CHOOSE picks a value by position instead.

SWITCH & CHOOSE

Match a value against a list of cases with SWITCH and add a default, plus how CHOOSE picks a value by position instead.

Logic

The cell or expression compared against each case below.

First value to match exactly. Text needs quotes; numbers do not.

Returned when the value equals case 1.

Second value to match exactly.

Returned when the value equals case 2.

Third value to match exactly.

Returned when the value equals case 3.

The lone trailing argument, returned when nothing matched. Leave it out and unmatched values return #N/A.

=SWITCH(A2, "N", "North", "S", "South", "E", "East", "Unknown")

Worked Example

Turn a one-letter region code in A2 into a full region name, with a fallback for codes you have not mapped.

=SWITCH(A2, "N", "North", "S", "South", "E", "East", "Unknown")

Returns: A2 containing S returns "South"; A2 containing W matches no case, so the trailing default returns "Unknown".

Checks Before You Paste

  • SWITCH only tests exact equality - it cannot do >= or <. For bands and ranges, either use IFS, or use the SWITCH(TRUE, ...) trick: =SWITCH(TRUE, A2>=90, "A", A2>=80, "B", "C") evaluates each condition and returns the result of the first that is TRUE.
  • The default is recognised purely by argument count: an odd argument at the end is the default, an even one starts a new pair. Delete a result by mistake and your intended default silently becomes a case value, which is the single most common SWITCH bug.
  • CHOOSE is the positional twin - =CHOOSE(2, "North", "South", "East") returns "South". Its index must land between 1 and 254; 0, a negative number, or an index past the last value returns #VALUE!, and a decimal like 2.7 is truncated down to 2.

How SWITCH & CHOOSE works

Availability: CHOOSE is in every version of Excel and in Google Sheets. SWITCH needs Excel 2019, Microsoft 365 or Excel for the web; Google Sheets has SWITCH. Excel 2016 and earlier show _xlfn.SWITCH and return #NAME?.

These two functions solve the same shape of problem from opposite ends. SWITCH matches a value against a list of cases and returns the result paired with the first case it equals. CHOOSE ignores values entirely and picks by position: give it 3 and it returns the third item in the list, whatever that item happens to be.

SWITCH is the readable way to translate codes into labels - region initials into region names, status flags into descriptions, weekday numbers into words. It compares with plain equality only. There is no >=, no BETWEEN, and no wildcards, so bands and ranges belong in IFS instead. Text comparison is case-insensitive, so the case "n" matches a cell containing N. Its default is not a named argument: it is simply a final argument with no partner, recognised by the fact that the argument count is even rather than odd. Omit it and an unmatched value returns #N/A.

CHOOSE takes a number from 1 up to 254 and returns the value in that position. Anything below 1 or beyond the last value supplied returns #VALUE!, and a decimal index is truncated toward zero, so 2.9 selects the second item. The index is usually the output of another function - MONTH, WEEKDAY, MATCH or RANDBETWEEN - which is where CHOOSE earns its place, since the list of results can be typed inline rather than kept in a lookup table.

CHOOSE has one property SWITCH does not: its values can be ranges, and it returns them as live references. That makes =SUM(CHOOSE(2, A2:A13, B2:B13, C2:C13)) a way to sum whichever column a control cell selects. Once a mapping grows past about ten entries, though, both functions become worse than a two-column table read with XLOOKUP, because a table can be edited by someone who does not want to open the formula bar.

Syntax

=SWITCH(expression, value1, result1, [value2, result2], ..., [default]) / =CHOOSE(index_num, value1, [value2], ...)
ArgumentRequiredWhat it does
expression (SWITCH)RequiredThe value being matched: a cell, a formula result, or TRUE when you are using the SWITCH(TRUE, ...) pattern.
value1 / result1 (SWITCH)RequiredThe first case and what to return for it. Cases are compared with exact, case-insensitive equality.
value2 / result2 ... (SWITCH)OptionalFurther case/result pairs, checked in order. SWITCH accepts 254 arguments in total, which is 126 pairs alongside the expression and a default.
default (SWITCH)OptionalA single trailing argument with no case in front of it, returned when nothing matched. Leave it out and unmatched values return #N/A.
index_num (CHOOSE)RequiredWhich position to return, from 1 to 254. Decimals are truncated toward zero; anything outside the range of supplied values returns #VALUE!.
value1 (CHOOSE)RequiredThe item returned when index_num is 1. Can be a number, text, a formula, a name, or a cell range.
value2, ... value254 (CHOOSE)OptionalThe remaining positions, in order. Every argument is evaluated whether or not it is the one selected, so an error in an unused slot still propagates.

More worked examples

A2 holds a date and you want to know whether it falls at the weekend.

=SWITCH(WEEKDAY(A2, 2), 6, "Weekend", 7, "Weekend", "Weekday")

Returns: A Saturday returns "Weekend"; a Tuesday matches neither case and the trailing default returns "Weekday".

WEEKDAY with return type 2 numbers Monday as 1, so 6 and 7 are Saturday and Sunday.

Turning a date in A2 into a fiscal quarter label without a lookup table.

=CHOOSE(MONTH(A2), "Q1", "Q1", "Q1", "Q2", "Q2", "Q2", "Q3", "Q3", "Q3", "Q4", "Q4", "Q4")

Returns: A date of 14 May returns "Q2", because MONTH gives 5 and the fifth value in the list is Q2.

Shifting the fiscal year start is a matter of rotating the twelve labels, not rewriting any logic.

A dashboard cell G1 holds 1, 2 or 3 to pick which of three monthly columns to total.

=SUM(CHOOSE($G$1, A2:A13, B2:B13, C2:C13))

Returns: With G1 = 2, the formula returns the sum of B2:B13.

CHOOSE returns the range itself as a reference, which is why SUM can operate on it. SWITCH cannot do this.

Common mistakes

CHOOSE index outside 1 to the last value
=CHOOSE(0, "A", "B", "C") and =CHOOSE(4, "A", "B", "C") both return #VALUE!. When the index comes from MATCH, a failed match returns #N/A and CHOOSE passes that straight through, so check the index on its own before blaming CHOOSE.
A decimal index silently truncates
=CHOOSE(A2/2, ...) with A2 = 5 gives an index of 2.5, and CHOOSE returns the second value without complaint. If the intent was to round, do it explicitly with ROUND or ROUNDUP so the behaviour is visible in the formula.
Expecting SWITCH to handle ranges
=SWITCH(A2, ">90", "A", ...) never matches, because SWITCH compares the literal text ">90" against A2 rather than evaluating it. For thresholds either use IFS, or use =SWITCH(TRUE, A2>=90, "A", A2>=80, "B", "C"), where each case is a comparison that evaluates to TRUE.
Deleting a result turns the default into a case
SWITCH decides what the last argument is purely by counting. Remove one result from the middle and the argument count flips, so the value you meant as a default is read as a case with no result - Excel then reports too few arguments, or worse, silently pairs the wrong things. Count the arguments in pairs after every edit.
Case sensitivity that is not there
=SWITCH(A2, "n", "North", "N", "New") can never reach the second case: the comparison is case-insensitive, so a cell containing N matches "n" first and returns "North". If upper and lower case must mean different things, use IFS with EXACT.

Frequently Asked Questions

Related Tools