This page isn't translated yet, so its text is in English. Function names and formulas are shown in your Excel language.
Excel function · Logic
SWITCH
Compares one value with a list and returns the matching result.
What it does
SWITCH looks at one value and compares it with a list of options. When it finds an exact match, it returns the result paired with it. A last, unpaired argument is the default for when nothing matches.
Syntax
=SWITCH(expression, value1, result1, [value2, result2], …, [default])Arguments in square brackets are optional, and … means you can add more of the same. In this Excel language, arguments are separated by ,
Arguments
- expression
- The value to compare, usually a cell.
- value
- A value to compare it with.
- result
- What to return when that value matches.
- default
- What to return when nothing matches. Without it, no match gives #N/A.
Example
Size codes are S, M and L. What size is the code in A2?
| A | B | |
|---|---|---|
| 1 | Code | Size |
| 2 | M | Medium |
The formula in B2:
=SWITCH(A2,"S","Small","M","Medium","L","Large","?")Result: Medium
A2 holds M. It doesn't match S but it does match M, so the result paired with M is returned: Medium.
Common mistakes
- Expecting comparisons such as greater than.
SWITCHonly checks exact matches; for bands of values useIFS. - Losing track of the pairs. Each value needs a result after it, and an odd extra argument at the end becomes the default.
In other Excel languages
Excel translates function names, and in some languages the argument separator too. Type the name your Excel shows.
| Excel language | Function name | Separator |
|---|---|---|
| English | SWITCH | , |
| Deutsch | ERSTERWERT | ; |
| Français | SI.MULTIPLE | ; |
| Español (España) | Not confirmed yet | ; |
| Español (México) | Not confirmed yet | , |
| 日本語 | SWITCH | , |
| 한국어 | SWITCH | , |
| 繁體中文 | SWITCH | , |
| ไทย | SWITCH | , |
| ខ្មែរ | SWITCH | , |
| Tiếng Việt | SWITCH | ; |