What it does
The first argument is the expression to compare: a cell or a formula such as WEEKDAY(A2,2). Value-result pairs follow: "C","Cash","D","Debit card". Whichever value the expression equals, the result next to it comes back. If one argument is left over after the pairs, it is the default.
Because the expression is written once, it is much shorter than nested IFs that compare the same cell again and again. The comparison is equality only; for range tests such as >=, use IFS.
It is available in Microsoft 365, Excel 2019 and later. To choose by a position number, use CHOOSE; if the options form a long list that changes often, a mapping table with VLOOKUP or XLOOKUP fits better.
Syntax
=SWITCH(expression, value1, result1, ..., [default])=İLKEŞLEŞEN(ifade; değer1; sonuç1; ...; [varsayılan])Arguments in square brackets are optional. English Excel separates arguments with commas (,) and uses a dot for decimals; Turkish Excel uses semicolons (;) and a decimal comma. Excel shows function names in its own language when it opens the file.
Arguments
| Argument | Required | Description |
|---|---|---|
expression | Required | The value or formula to compare, e.g. B2. |
value1 | Required | The first value to compare expression with. |
result1 | Required | The result returned if expression equals value1. Further pairs follow as value2, result2; up to 126 pairs are allowed. |
default | Optional | The result returned when no value matches. If omitted, #N/A is returned. |
Examples
1Turn a payment code into a name
The one-letter code in column B is compared with three values. For a code that matches none of them, the last argument, the default, is returned.
=SWITCH(B2,"C","Cash","D","Debit card","T","Bank transfer","Check code")| A | B | C | |
|---|---|---|---|
| 1 | Order | Payment Code | Payment Type |
| 2 | SO-701 | C | Cash |
| 3 | SO-702 | D | Debit card |
| 4 | SO-703 | T | Bank transfer |
| 5 | SO-704 | D | Debit card |
| 6 | SO-705 | X | Check code |
- C2 (filled down to C6)
=SWITCH(B2,"C","Cash","D","Debit card","T","Bank transfer","Check code")
SO-702 shows Debit card and SO-703 shows Bank transfer. The "X" in SO-705 matches none of the listed values, so it gets Check code.
We recalculated this example in real Excel (Microsoft 365, 16.0) and compared the results: they match.
2Overtime rate multiplier by day
Under the company rule, Saturday overtime is paid at 1.5 times and Sunday at 2 times. The expression is a WEEKDAY formula; days other than 6 and 7 get the default multiplier of 1. Column D works out the pay.
=SWITCH(WEEKDAY(A2,2),6,1.5,7,2,1)| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Date | Hours | Multiplier | Pay | Hourly Rate | |
| 2 | 6-Nov-2026 | 3 | 1 | 750.00 | 250.00 | |
| 3 | 7-Nov-2026 | 5 | 1.5 | 1,875.00 | ||
| 4 | 8-Nov-2026 | 4 | 2 | 2,000.00 | ||
| 5 | 9-Nov-2026 | 2 | 1 | 500.00 |
- C2 (filled down to C5)
=SWITCH(WEEKDAY(A2,2),6,1.5,7,2,1) - D2 (filled down to D5)
=B2*$F$2*C2
The multiplier is 1.5 on Saturday and 2 on Sunday. Four hours on Sunday 8 November pay 2,000.00; three hours on Friday 6 November pay 750.00.
We recalculated this example in real Excel (Microsoft 365, 16.0) and compared the results: they match.
Common errors and fixes
- #N/A
Cause: The expression matched none of the values and no default was given.
Fix: Add a default as the last argument:
,"Check code".- Code not matched
Cause: The code in the cell has a trailing space, or it is stored as a number while the formula has it as text (
"1"against 1).Fix: Clean the codes with TRIM; write number codes without quotes in the formula.
Good to know
- List values that share a result as separate pairs:
SWITCH(WEEKDAY(A2,2),6,"Weekend",7,"Weekend","Weekday"). - Text comparisons are not case-sensitive: "c" and "C" count as the same.
In Nexell
Get Nexell to do it from a sentence
Add a column to the order list that turns the payment codes C, D and T into Cash, Debit card and Bank transfer, and writes "Check code" for unknown codes
Convert to tableBring your order list into the tool and type this. Nexell adds the column with real Excel formulas and the preview shows any unknown codes; in the downloaded file, the description changes when the code does.
Nexell uses AI to understand the request and builds the result with real Excel formulas; the formula may differ from the example on this page. You see a preview first and nothing changes until you press Apply; formulas stay live in the downloaded .xlsx file.
Free account · no card needed · 30 credits a month
Frequently asked questions
What is the difference between SWITCH and IFS?
SWITCH compares one expression with values for equality and can take a default. IFS tests a separate condition in each pair; use it for range comparisons such as B2>=85.
Related functions
- IFSÇOKEĞER · Returns the value of the first true condition.
- CHOOSEELEMAN · Chooses a value from a list by position.
- IFEĞER · Returns one value if a condition is true and another if false.
- XLOOKUPÇAPRAZARA · Searches an array and returns the matching item; the fourth argument if not found.
- VLOOKUPDÜŞEYARA · Looks up a value in the first column and returns a value from the same row. Use 0 as the last argument for exact match.