Logic function
Excel SWITCH function
SWITCH checks one value against a list of possible matches and returns the result paired with the first match. It is a tidy replacement for a long nested IF that keeps testing the same cell, such as turning region codes into names. Add a final default argument for anything that does not match.
=SWITCH(expression, value1, result1, [default_or_value2], ...)Arguments
expression- The value to check, usually a cell.
value1- The first value to compare with.
result1- What to return when the expression equals value1.
default_or_value2- More value and result pairs, up to 126. A final argument with no partner is the default when nothing matches.
SWITCH examples
Every result below was calculated from this sample sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Order | Region code | Ship date | Score |
| 2 | SO-71 | N | Nov 2, 2026 | 91 |
| 3 | SO-72 | E | Nov 7, 2026 | 84 |
| 4 | SO-73 | W | Nov 4, 2026 | 77 |
| 5 | SO-74 | S | Nov 8, 2026 | 68 |
| 6 | SO-75 | X | Nov 5, 2026 | 95 |
Download this sheet as an Excel practice file (.xlsx)
Result: North
B2 is N, so the result is North. Any code not in the list would return the default, Unknown.
Result: #N/A
B6 holds X, which matches nothing, and there is no default, so SWITCH returns #N/A.
Result: Weekend
November 7, 2026 is a Saturday, WEEKDAY 7, so the order shipped at the weekend.
Result: B
SWITCH(TRUE,...) returns the result for the first test that is TRUE: 84 is a B. IFS says the same thing more plainly.
How to use SWITCH
- Click the cell for the result.
- Type =SWITCH( and the cell to check.
- Add pairs of value, result: "N","North".
- End with a default value for anything else, then press Enter.
Common SWITCH mistakes
No default
Without a final default, an unmatched value returns #N/A. Add one, even if it is just "Check".
Expecting greater-than tests
SWITCH only tests for equal values. For bands such as scores of 80 and above, use IFS, or SWITCH(TRUE,...), or a lookup table.
A number against text
SWITCH compares types strictly: the number 1 does not match the text "1". Convert with VALUE or TEXT first.
SWITCH FAQ
What is the difference between SWITCH and IFS?
SWITCH compares one value against exact matches and can have a default. IFS takes any tests, such as B2>=80, and returns #N/A unless you end with TRUE and a fallback.
Is SWITCH case-sensitive?
No. "n" matches "N". For a case-sensitive match use IF with EXACT.
Which versions of Excel have SWITCH?
Excel 2019, Excel 2021, Microsoft 365 and Excel for the web. In Excel 2016 and earlier it returns #NAME?.
Guides that use SWITCH
Related functions
IFSFirst true test winsIFPicks a result from a testCHOOSEPicks a value by its numberXLOOKUPModern lookup in any direction
Updated