Learn Excel
EN
Sets how numbers, dates and formulas look, so everything works just like your own Excel.

Home › Excel functions › SWITCH

SWITCH Function in Excel: Syntax and Examples

SWITCH compares one value with a list of options and returns the result for the option that matches. It's ideal for turning codes into names: "NL" into Netherlands, 1 into Monday, "P" into Paid.

In this guide
  1. SWITCH syntax
  2. Basic example
  3. Try it yourself
  4. Numbers to names
  5. The SWITCH(TRUE) trick
  6. SWITCH vs. IFS
  7. In practice: the VAT rate per country
  8. Keep learning
  9. FAQ

SWITCH syntax

=SWITCH(expression, value1, result1, [value2, result2], …, [default])
ArgumentWhat it means
expressionThe value to check, usually a cell.
value / resultPairs: if the expression equals this value, return this result.
default
(optional)
A last, unpaired value returned when nothing matches. Without it you get #N/A.

SWITCH is available in Excel 2019, 2021, 2024 and Microsoft 365.

Basic example: status codes

AB
1CodeStatus
2PPaid
3OOpen
4CCancelled
5XUnknown
=SWITCH(A2, "P", "Paid", "O", "Open", "C", "Cancelled", "Unknown")

"P" matches the first value, so B2 shows Paid. "X" matches nothing and gets the default: Unknown.

SWITCH practice: try it yourself

Reading is one thing, typing it is another. Build the formula below step by step: the tips tell you what to type next, and you can click or drag across cells to add them, just like in Excel.

Task: Turn the priority number in B2 into a word, in C2: =SWITCH(B2,1,"Low",2,"Medium",3,"High")

Numbers to names: weekday names

=SWITCH(WEEKDAY(A2, 2), 6, "Weekend", 7, "Weekend", "Weekday")

WEEKDAY with type 2 returns 1 for Monday through 7 for Sunday. Saturday (6) and Sunday (7) return "Weekend"; anything else "Weekday".

The SWITCH(TRUE) trick for ranges

SWITCH only checks for equal values, so it can't do "greater than" directly. A common trick is to switch on TRUE and use conditions as the values:

=SWITCH(TRUE, B2>=80, "A", B2>=70, "B", B2>=60, "C", "F")

This works, but IFS is usually clearer for ranges.

SWITCH vs. IFS vs. a lookup table

  • SWITCH: one value, compared to a handful of fixed options. Short and readable.
  • IFS: different conditions or comparisons like >= and <.
  • A lookup table with XLOOKUP: more than about 5 options, or options that change. Easier to maintain than a long formula.

In practice: the VAT rate per country

A company invoices customers in four countries and needs the standard VAT rate for each. With the country code in column B, SWITCH picks the rate:

ABCDE
1InvoiceCountryAmountVAT rateVAT
2F-101NL€200.0021%€42.00
3F-102DE€500.0019%€95.00
4F-103FR€150.0020%€30.00
5F-104BE€80.0021%€16.80
  • D2: =SWITCH(B2, "NL", 0.21, "DE", 0.19, "FR", 0.2, "BE", 0.21, 0)
  • E2: =C2*D2

SWITCH compares B2 with each code in turn and returns the value next to the first match. The final 0 is the fallback for any other country, so you never get #N/A.

Frequently asked questions

Why does SWITCH return #N/A?

No value matched and there's no default. Add a final, unpaired argument as the default.

Is SWITCH case-sensitive?

No. "p" and "P" match the same value.

Can SWITCH match multiple values to one result?

You have to repeat the result for each value, as in the weekend example. For many values, a lookup table is simpler.