Excel SWITCH function
SWITCH maps one value to several outcomes: region code to name, month number to text, status code to action. It compares for equality only, so range tests like A2>90 are not possible — that is IFS territory.
Logic · Available in: Excel 2019 and Excel 365
Syntax
SWITCH(expression, value1, result1, [value2, result2], ..., [default])What it returns The result paired with the first value equal to the expression; the default, or #N/A, if nothing matches.
| Arguments | ||
|---|---|---|
| expression | required | The value being compared; it is evaluated once. |
| value1 | required | The first candidate, compared to the expression for equality. |
| result1 | required | The result to return when that candidate matches. |
| default | optional | A single trailing argument returned when nothing matches. |
Examples
Size code to label
| Code | Label |
| M | |
| XL | |
| XS |
= SWITCH(A2,"S","Small","M","Medium","L","Large","Other size")→ Medium
M equals the second candidate, so the formula returns Medium. The final "Other size" stands alone rather than in a pair, which is how SWITCH recognises it as the default.
Month number to name
| Month | Name |
| 3 | |
| 11 |
= SWITCH(A2,1,"Jan",2,"Feb",3,"Mar","Unknown")→ Mar
3 matches the third candidate. With twelve months this gets long — TEXT(DATE(2026,A2,1),"mmm") is the better answer there. SWITCH shines at four to six branches.
Common mistakes
- 1.Writing range conditions into SWITCH: SWITCH(A2,>90,"A") is not valid syntax. Use IFS.
- 2.Pairing the default ("x","y"). SWITCH's default must be one lone final argument.
- 3.Assuming case matters — comparison is exact but case-insensitive, so "m" and "M" both match; "M " with a trailing space does not, and needs TRIM.
How to use it
- 1.Click the cell where the result should appear.
- 2.Type = then the function name, and press Tab to accept it.
- 3.Enter each argument separated by commas; ranges can be dragged with the mouse.
- 4.Press Enter. Drag the fill handle down if the same formula applies to more rows.
Frequently asked questions
What is the syntax of SWITCH?
SWITCH(expression, value1, result1, [value2, result2], ..., [default]). What it returns: The result paired with the first value equal to the expression; the default, or #N/A, if nothing matches.
Which Excel versions support SWITCH?
Excel 2019 and Excel 365. It is available in every desktop version unless the note above says otherwise.
Why does SWITCH return an error instead of a value?
Writing range conditions into SWITCH: SWITCH(A2,>90,"A") is not valid syntax. Use IFS.