Excel SWITCH: Cleaner Alternatives to Nested IF
By Szabó Gergő · Updated
SWITCH compares one expression to a list of values and returns the matching result. It is cleaner than nested IF when you are matching exact codes rather than ranges.
Syntax and arguments
=SWITCH(expression, value1, result1, [value2, result2], ..., [default])- expression
- The cell or formula to compare.
- value1
- The first exact value to match.
- result1
- Returned when the expression equals value1.
- default
- Optional final argument used when nothing matches.
SWITCH examples
Code in B2 is O, P, or C.
=SWITCH(B2,"O","Open","P","Paid","C","Closed","Unknown")Unknown is the default when the code is blank or unexpected.
Month number is A2.
=SWITCH(A2,1,"Jan",2,"Feb",3,"Mar",4,"Apr",5,"May",6,"Jun",7,"Jul",8,"Aug",9,"Sep",10,"Oct",11,"Nov",12,"Dec","")Each month is an exact match; invalid numbers return blank.
Sign of variance in C2.
=SWITCH(SIGN(C2),-1,"Under",0,"Flat",1,"Over")The expression can be SIGN, LEFT, or another formula, not only a cell.
Common mistakes
Using SWITCH for ranges such as >=90
SWITCH is exact match. Use IFS or nested IF for thresholds.
Omitting a default
Unmatched values return #N/A. Pass a final default argument.
Number versus text codes
Match the type in the source cell. "1" and 1 are different.
SWITCH FAQ
Should I use SWITCH or IFS?
SWITCH for one expression versus exact values. IFS for independent TRUE/FALSE tests and numeric bands.
Can SWITCH use wildcards?
No. Use IFS with SEARCH or FILTER for pattern matching.
Is SWITCH available in Google Sheets?
Yes. Sheets also has SWITCH with the same exact-match idea.