FormulaCamp
Completed
← All functions
Logic

SWITCH

Picks a result by exact match.

Syntax

SWITCH(expression, value1, result1, …, [default])

Example: =SWITCH(A2,"Boston","East","Denver","Central","Other")

Available in: Excel 2019+

SWITCH compares one expression against a list of values and returns the result for the first match, with an optional default: =SWITCH(expression, value1, result1, …, default). It is cleaner than nested IFs when you test one cell against fixed codes.

When to use it

Arguments explained

Worked examples

Code to label

A
1Code
2W

Formula: C1: =SWITCH(A2,"E","East","W","West","N","North","Unknown")

Result: West

A2 is compared with each code in turn; the last lone argument is the default.

Weekend or weekday

A
1Date
23/9/2024

Formula: C1: =SWITCH(WEEKDAY(A2),1,"Sun",7,"Sat","Weekday")

Result: Sat

WEEKDAY returns 7 for Saturday, so the second pair matches. March 9, 2024 is a Saturday.

Ranges by switching on TRUE

A
1Units
275

Formula: C1: =SWITCH(TRUE,A2<50,"Low",A2<100,"Mid","High")

Result: Mid

Each test returns TRUE or FALSE; SWITCH picks the first one that equals TRUE.

Try it

A tiny spreadsheet with example data. Edit the formula or any number and see the result.

Formula in F2: =SWITCH(C2,"Yes","Bonus","No","None","Other")

Example spreadsheet for SWITCH
ABCDEF
1StudentScoreExtra creditAttemptsResult
2Ann92Yes2Bonus
3Bob74No0
4Cy58Yes3
5Dee81No1
6Eli662
Result in F2: Bonus
Practice this in a lesson: SWITCH, XOR, IFNA, EXACT

Common errors and how to fix them

Related functions

Frequently asked questions

When should I use SWITCH instead of IFS?
Use SWITCH when you compare one value to exact alternatives, and IFS when each branch has its own condition.
Does SWITCH support ranges like greater than?
Not directly. Switch on TRUE and write each comparison as a value.
Is SWITCH case sensitive?
No.
What if I have dozens of codes?
Put them in a two-column table and use XLOOKUP or VLOOKUP instead.

More in Logic