What it does
SWITCH compares one expression against several possible values and returns the matching result.
Syntax or pattern
=SWITCH(expression, value1, result1, [value2, result2], [default])5 practical examples
Convert codes to labels
Turn status codes into readable text.
=SWITCH(A2,"N","New","P","Pending","C","Closed","Unknown")Great for code mapping.
Month number to quarter
Return the quarter for a month number.
=SWITCH(ROUNDUP(A2/3,0),1,"Q1",2,"Q2",3,"Q3",4,"Q4")This avoids a long nested IF formula.
Priority code labels
Convert priority codes into labels.
=SWITCH(B2,1,"Low",2,"Medium",3,"High","Check")Add a default result at the end.
Department abbreviations
Expand department abbreviations.
=SWITCH(C2,"HR","Human Resources","FIN","Finance","OPS","Operations","Other")Useful for small mapping lists.
Choose calculation type
Return a different calculation based on a selected option.
=SWITCH(E2,"Margin",Profit/Sales,"Tax",Sales*TaxRate,"")For larger calculation choices, a lookup table may be easier to maintain.
Common mistakes to avoid
- Using SWITCH for numeric ranges where IFS is better.
- Forgetting the default result.
- Creating formulas that should be lookup tables.
Related Excel examples
FAQ
When should I use SWITCH instead of IFS?
Use SWITCH when you compare one value to several exact matches.