Logical function

SWITCH function

Compares one value against a list of options and returns the result paired with the first exact match, with an optional default.

Available in Microsoft 365, Excel 2019 and later, Excel for the web

Excel 2019 and laterWorks in Google Sheets

Syntax

SWITCH(expression, value1, result1, [value2, result2], ..., [default])
ArgumentWhat it means
expressionRequiredThe value to test — a cell, or a formula such as WEEKDAY(A2). It is written only once.
value1, result1RequiredThe first value to compare against, and what to return if it matches.
value2, result2, ...OptionalMore value/result pairs, up to 126 pairs.
defaultOptionalA single final argument without a partner, returned when nothing matches. Without it, no match gives #N/A.

Returns: The result of the first matching value, the default, or #N/A.

How SWITCH works

SWITCH translates one value into another. You give it the thing to look at — a region code, a status number, a weekday — and then a list of possible values with the result for each. It returns the result for the first exact match. Codes to names, numbers to labels and short category mappings are classic SWITCH jobs.

Its advantage over IFS or nested IF is that the expression is written once. Compare =IF(B2="N","North",IF(B2="S","South",...)) with =SWITCH(B2,"N","North","S","South",...). The comparisons are exact equality, case-insensitive for text. If the number of arguments after the expression is odd, the last one is treated as the default value.

SWITCH cannot test ranges like "greater than 90" directly. A common workaround is SWITCH(TRUE, B2>=90, "A", B2>=75, "B", "C"): each condition is compared with TRUE, and the first one that is TRUE wins.

Examples

1Region code to region name

C2fx=SWITCH(B2, "N", "North", "S", "South", "E", "East", "W", "West", "Unknown")
ABC
1StoreCode
2LyonEEast
3NantesW
4LilleN

Result: East

B2 holds E, which matches the third pair, so SWITCH returns East. Any code not in the list would return the default, Unknown.

2Weekend or weekday

B2fx=SWITCH(WEEKDAY(A2), 1, "Sunday", 7, "Saturday", "Weekday")
AB
1Delivery date
22026-03-14Saturday
32026-03-16

Result: Saturday

14 March 2026 is a Saturday, so WEEKDAY returns 7 and SWITCH returns Saturday. Monday 16 March gives 2, which matches nothing, so the default Weekday appears.

3Priority number with no default

C2fx=SWITCH(B2, 1, "Low", 2, "Medium", 3, "High")
ABC
1TaskPriority
2Order toner4#N/A

Result: #N/A

The value 4 matches none of the listed values and there is no default, so SWITCH returns #N/A.

4Bands with SWITCH(TRUE, ...)

C2fx=SWITCH(TRUE, B2>=90, "A", B2>=75, "B", "C")
ABC
1StudentScore
2Ravi77B

Result: B

Each condition is evaluated and compared with TRUE. B2>=90 is FALSE, B2>=75 is TRUE, so B is returned. The lone "C" at the end is the default.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 18 KB

Common errors and how to fix them

ErrorWhy it happensFix
#N/ANo value matched and no default was given.Add a final default argument.
#NAME?Opened in Excel 2016 or earlier, which does not have SWITCH.Use nested IF or CHOOSE for older versions.

Tips

  • Numbers and text are different values: a code typed as the number 1 does not match "1". Keep the list consistent with how the data is stored.
  • For long mappings (more than about ten items) keep a two-column table and use XLOOKUP — it is easier to maintain than a very long formula.

Questions

What is the difference between SWITCH and IFS?

SWITCH compares one expression against exact values; IFS evaluates independent conditions, so it can test ranges like >=75. SWITCH also has a built-in default argument, IFS needs a TRUE pair.

Is SWITCH case-sensitive?

No. "east" matches East.

Google Sheets

SWITCH also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

SWITCH in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishSKIFT
DutchSCHAKELEN
FinnishMUUTA
FrenchSI.MULTIPLE
GermanERSTERWERT
HungarianÁTVÁLT
Norwegian (Bokmål)BRYTER
PolishPRZEŁĄCZ
Portuguese (Brazil)PARÂMETRO
Portuguese (Portugal)PARÂMETRO
RussianПЕРЕКЛЮЧ
SpanishCAMBIAR
SwedishVÄXLA
TurkishİLKEŞLEŞEN

Recipes that use SWITCH