SWITCH Function

Compares one value against a list of options and returns the matching result.

Category

Logical

Available in

Excel 2019+, Microsoft 365

Returns

The result paired with the first matching value

Want to practice SWITCH in a real spreadsheet? Open a blank sheet in our Practice Sandbox and try it with live data, with the AI Excel tutor beside you. No Excel needed — just a free account.Try it free in the Sandbox

Overview

SWITCH looks at one value and finds it in a list of exact options — like a small lookup table written right inside the formula.

It's tidier than nested IFs when every test is “is this cell equal to …?”. Add a final unpaired value as the default.

Syntax

=SWITCH(expression, value1, result1, [value2, result2], …, [default])

Arguments

ArgumentRequired?What it does
expressionYesThe value to compare, such as a cell or a calculation.
value1, result1YesThe first option and what to return when expression matches it.
value2, result2, …OptionalMore option/result pairs, up to 126.
defaultOptionalReturned when nothing matches. Without it, no match gives #N/A.

Examples

Example 1 — Region codes to names

Northstar's system exports one-letter region codes.

C2fx=SWITCH(B2, "N", "North", "S", "South", "E", "East", "W", "West", "Unknown")
ABC
1OrderCodeRegion
21001EEast
31002WWest
41003NNorth
51004XUnknown
=SWITCH(B2, "N", "North", "S", "South", "E", "East", "W", "West", "Unknown") Explain

Example 2 — Switching on a calculation

Label a date as Weekend or Weekday.

=SWITCH(WEEKDAY(A2), 1, "Weekend", 7, "Weekend", "Weekday") Explain

Example 3 — The SWITCH(TRUE) trick

Compare against TRUE to use ranges instead of exact values.

=SWITCH(TRUE, B2>=90, "A", B2>=80, "B", "C") Explain
This works, but IFS is usually clearer for ranges. Keep SWITCH for exact matches.

Common mistakes

  • #N/A errors. No option matched and there's no default. Add one at the end.
  • Numbers stored as text. The number 1 doesn't match the text "1". Make sure the types agree.

Notes

  • If the list of options changes often, keep it in a table and use XLOOKUP instead.
  • Related functions: IFS, IF, CHOOSE, XLOOKUP.
Kyle Stott

Author

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.