SWITCH Function

Excel Functions › Logical

Excel 2019+ Excel 365

The Excel SWITCH function compares one expression against a list of values and returns the result paired with the first exact match — with an optional default for everything else. Where IFS repeats the cell in every test (A2="N", …, A2="S", …), SWITCH names it once and lists the alternatives. Translating codes, day numbers, and status flags has never been tidier.


Quick answer: to turn a weekday number in A2 into a name, with a fallback:
=SWITCH(A2, 1, "Mon", 2, "Tue", 3, "Wed", 4, "Thu", 5, "Fri", 6, "Sat", 7, "Sun", "Invalid")
The lone unpaired argument at the end is the default — returned when nothing matches. Matching is exact-value only: no >=, no wildcards.

Syntax

=SWITCH(expression, value1, result1, [value2, result2], ..., [default])
ArgumentDescription
expressionRequiredThe value to compare — a cell, a calculation, or a function result. Evaluated once.
value1, result1RequiredIf expression exactly equals value1, SWITCH returns result1.
value2, result2, …OptionalUp to 126 value/result pairs, checked in order.
defaultOptionalA final unpaired argument returned when no value matches. Omit it and an unmatched expression returns #N/A.

Available in: Excel 2019 and later, Excel for Microsoft 365, and Excel for the web. Excel 2016 and earlier show #NAME?.

Translate codes to labels

Region codes in A2:A5, full names in B2 copied down. The unmatched “Q” falls through to the default:

AB
1CodeRegion
2NNorth
3SSouth
4WWest
5QUnknown
=SWITCH(A2, "N", "North", "S", "South", "W", "West", "Unknown") // last lone argument = default

Text matching is case-insensitive, like most of Excel: "n" and "N" both match. The expression can be a calculation too:

=SWITCH(WEEKDAY(A2, 2), 6, "Weekend", 7, "Weekend", "Weekday") // two values can share a result by repeating it

Try it: interactive SWITCH demo

Live demo

Pick a day number and watch SWITCH hunt for an exact match — then feed it a 9 to see the default earn its keep.

SWITCH vs IFS: exact values vs conditions

The two functions divide the territory cleanly. SWITCH owns exact-value matching — one expression, many candidates:

=SWITCH(A2, "PO", "Purchase order", "INV", "Invoice", "CR", "Credit note", "Check the code")

IFS owns conditions — SWITCH simply cannot express a comparison operator. This logic has no SWITCH equivalent:

=IFS(B2>=90, "A", B2>=80, "B", TRUE, "F") // ranges need IFS, not SWITCH

Rule of thumb: if every branch starts with the same cell =, use SWITCH; if branches use >=, <, or test different cells, use IFS.

Long lists belong in a table. Past eight or ten pairs, move the code–label pairs onto a sheet and use XLOOKUP instead — easier to edit, and other formulas can reuse the table. SWITCH’s cousin CHOOSE handles the special case where the expression is already a tidy index 1, 2, 3…

Errors & common pitfalls

#N/A — nothing matched and no default. Add a final unpaired argument as the default, or wrap the formula in IFNA.

#NAME? — older Excel. SWITCH needs Excel 2019 or later (or Microsoft 365). For earlier versions, rewrite with nested IF or a lookup table.

Pitfall: trying to use operators. =SWITCH(B2, >=90, "A", …) is a syntax error — SWITCH compares values for equality only. Range logic belongs to IFS.

Pitfall: number vs text mismatch. The number 1 does not match the text "1". If the expression column holds text-formatted digits, quote your values — or convert with VALUE() first.

Pitfall: a default that hides typos. A catch-all like "Other" quietly absorbs misspelled codes. During development, set the default to something loud — "CHECK: " & A2 — so bad inputs surface.

Practice workbook

📊
Download the free SWITCH practice workbook
Every example on this page, ready to open in Excel — plus practice challenges with answers on a separate tab. No sign-up required.

Frequently asked questions

What's the difference between SWITCH and IFS?
SWITCH compares one expression against a list of exact values; IFS evaluates independent logical tests. SWITCH can’t use operators like >= — for ranges or multi-cell conditions you need IFS. For pure code-to-label translation, SWITCH is shorter because the expression is written once.
How do I add a default value to SWITCH?
Add one final argument without a partner: =SWITCH(A2, "N", "North", "S", "South", "Unknown"). Because it has no value to pair with, Excel treats it as the default for anything unmatched.
Can SWITCH test greater-than or less-than conditions?
No. SWITCH is exact-match only. For comparisons, use IFS: =IFS(B2>=90,"A", B2>=80,"B", TRUE,"F"). A common workaround you may see online - SWITCH(TRUE, ...) - works but is just IFS with extra steps.
Which Excel versions support SWITCH?
Excel 2019, Excel 2021, Excel for Microsoft 365, and Excel for the web. Excel 2016 and earlier show #NAME?.
Can two values return the same result in SWITCH?
Yes, but each needs its own pair — repeat the result: =SWITCH(WEEKDAY(A2,2), 6, "Weekend", 7, "Weekend", "Weekday"). SWITCH has no “6 or 7” shorthand.

Master functions like this in one day

This page covers one function. Our Excel Formulas and Functions class covers the 30 that matter most — live, hands-on, taught by professionals in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related functions: IFS · IF · CHOOSE · IFNA · XLOOKUP