formulastreak

Logic and errors function

SWITCH function in Google Sheets and Excel

SWITCH compares one value with a list of exact matches and returns the result paired with the first match, or a default.

Checked against Microsoft's and Google's documentation on · Example calculated on a live sheet

Syntax

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

Arguments in [brackets] are optional. Google Sheets writes it SWITCH(expression, case1, value1, [default or case2, value2], …).

Example

=SWITCH(D2,"Basic","B","Pro","P","Team","T","?") reads: Look at the plan in D2: Basic becomes B, Pro becomes P, Team becomes T, and anything else becomes ?.

Member sign-ups · edit F2 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultF2 = P
ABCDEF
1EmailNameAgePlanJoinedCode
2mara@example.comMara34Pro12 Jan 2026P
3jonas@example.orgJonas41Basic15 Jan 2026B
4MARA@example.comMara O.34Pro20 Jan 2026P
5priya@example.netPriyaTeam2 Feb 2026T
6tomas@example.comTomásn/abasic9 Feb 2026B
7elif@example.orgElif29Pro17 Feb 2026P
8jonas@example.orgJonas Lind41Basic23 Feb 2026B
9kenji@example.netKenji52Enterprise3 Mar 2026?
10sofia@example.comSofia23Team8 Mar 2026T
11leo@example.orgLeo17Basic14 Mar 2026B

F2 shows P for Mara's Pro plan; row 9's Enterprise isn't in the list, so it falls through to the default, ?.

How the spreadsheet calculates it

Compares D2 with each case and returns the matching result: "Basic" → "B", "Pro" → "P", "Team" → "T"; anything else → "?".

  1. 1. SWITCH: Compares D2 with each case and returns the matching result: "Basic" → "B", "Pro" → "P", "Team" → "T"; anything else → "?".
    • value = `D2`: the cell to look at
    • match1 = `"Basic"`: a value it might equal
    • result1 = `"B"`: what to show when it does. Add more match/result pairs
    • default = `"Pro"`: optional
    • default = `"P"`: optional
    • default = `"Team"`: optional
    • default = `"T"`: optional
    • default = `"?"`: optional

More SWITCH examples

  • =SWITCH(D2,"Basic","B","Pro","P","Team","T","?")A letter per plan, ? for anything else.
  • =SWITCH(WEEKDAY(A2,2),6,"Weekend",7,"Weekend","Weekday")Weekend or Weekday from a date.
  • =SWITCH(B2,"N","North","S","South","Unknown")Region names from one-letter codes.

Paste any of these into the formula explainer to see it step by step.

Tips

  • Always end with a default, so new codes in the data show something readable instead of #N/A.
  • Clean the value first (TRIM, UPPER) if the data may contain stray spaces or mixed case.
  • Move long code lists into a two-column table and use XLOOKUP, so updating a label doesn't mean editing the formula.
  • SWITCH compares exact values only; for bands like “70 and above”, use IFS or an approximate lookup instead.

What SWITCH is used for

Turning codes into labels (plan codes, region codes, status numbers), mapping weekday numbers to names, and replacing chains of IF that compare the same cell with different values.

Arguments

ArgumentRequiredWhat it is
expressionYesThe value to compare, usually a cell.
value1, result1YesA value it might equal, and what to return if it does. Add more pairs.
defaultNoA last, unpaired argument: returned when nothing matches.Watch out: Without it, an unmatched value gives #N/A.

Common mistakes

  • Using SWITCH for ranges like “at least 70”: it only does exact matches. Use IFS.

  • Using SWITCH for ranges like “at least 70”: it only tests exact equality. Use IFS or an approximate lookup.

  • Forgetting the default, so a new value in the data shows #N/A.

In Google Sheets

Google Sheets has SWITCH with the same arguments, including the unpaired default at the end.

Errors you may see with SWITCH

  • #N/A: No value matched and there's no default.
  • #NAME?: The file is open in Excel 2016 or older, which doesn't have SWITCH.

Questions

SWITCH or IFS?

SWITCH when one value is compared with exact matches; IFS when each condition is its own test, like score bands. See nested IF vs IFS vs SWITCH.

Is SWITCH case-sensitive?

Microsoft's page doesn't say, and we haven't confirmed it, so don't rely on case either way; clean the text first with UPPER or PROPER.

How many pairs can SWITCH take?

Microsoft's page allows up to 126 value and result pairs. Long lists are easier to maintain as a two-column table with XLOOKUP.

Sources

Official documentation the facts on this page were checked against.

Practise SWITCH on a live sheet

Lesson 13, IFS and SWITCH (Unit 3, Decisions), has 3 graded exercises, checked instantly, with steps and hints when you're stuck. Pro