SWITCH Function: A Cleaner Alternative to Nested IFs

SWITCH Formula in Excel Blogpost Feature Image
Learn how to use the SWITCH function in Excel to replace nested IF formulas. Covers syntax, default values, SWITCH(TRUE) for range tests, and a full comparison with IFS.

Nested IF formulas grow in one direction: outward. Each additional condition adds another layer of brackets. By the fourth or fifth layer, the formula becomes difficult to read, harder to audit, and easy to break when edited. The SWITCH function solves this problem directly. It maps a single expression to a list of possible values and returns the result for the first match — all in one clean, flat formula.

SWITCH is ideal whenever you need to convert a code, label, or number into another value. Status codes become plain-English labels. Numeric weekdays become day names. Region abbreviations become full region names. Furthermore, a default value at the end handles every unmatched case gracefully.

Availability: SWITCH requires Excel 2019, Excel 2021, Excel 2024, or Microsoft 365. It is not available in Excel 2016 or earlier. For older versions, use nested IF or IFS instead.

What Is the SWITCH Syntax?

SWITCH compares one expression against up to 126 values and returns the result for the first match.

=SWITCH(expression, value1, result1, [value2, result2], ..., [default])
ArgumentRequired?What it does
expressionRequiredThe value to test. This is usually a cell reference, but can also be a formula. The expression is evaluated once, then compared against each value in turn.
value1, result1RequiredThe first match/result pair. If expression equals value1, SWITCH returns result1 immediately and stops testing further pairs.
value2, result2…OptionalAdditional match/result pairs, up to 126 total. Each pair must be complete — you cannot have a value without its result.
defaultOptionalThe value to return when no match is found. Without a default, SWITCH returns #N/A on no match. Add a default as the final odd argument (not a value/result pair).

How Does SWITCH Compare to Nested IF and IFS?

All three approaches can produce the same output. However, each has a different strength. SWITCH is the clearest when the expression is a single cell and you are matching against fixed values. IFS is better for range-based tests (greater than, less than). Nested IF works in all Excel versions, making it the fallback for older files.

FeatureSWITCHIFSNested IF
Expression written once?✅ Yes❌ Repeated per condition❌ Repeated per condition
Supports range tests (>, <)?❌ Exact match only✅ Yes✅ Yes
Default / catch-all✅ Final argument✅ TRUE workaround✅ Final else clause
Max conditions126 pairs12764 (Excel 2007+)
Available in Excel 2016?❌ No❌ No✅ Yes
Best forExact value mappingRange and logic testsLegacy compatibility
SWITCH only does exact matching: You cannot write =SWITCH(A2, >100, "High", <=100, "Low"). For range-based tests, use IFS or nested IF instead. However, you can pass an expression as the first argument — for example =SWITCH(MOD(A2,2), 0, "Even", 1, "Odd") — to handle logic within SWITCH indirectly.

Example 1: Map a Code to a Label

The most common use of SWITCH is converting a short code into a readable label. Department codes, status abbreviations, region identifiers, and product categories are all good candidates. SWITCH handles each case cleanly and returns a default when the code is unrecognised.

1
Convert department codes to full department names
A — Code
B — SWITCH result
C — Nested IF equivalent
MKT
Marketing
Marketing
SLS
Sales
Sales
FIN
Finance
Finance
XYZ
Unknown
Unknown
SWITCH — expression written once, each pair is value → result: =SWITCH(A2, "MKT", "Marketing", "SLS", "Sales", "FIN", "Finance", "HR", "Human Resources", "OPS", "Operations", "Unknown") ← default for unrecognised codes Nested IF equivalent — notice how A2 is repeated five times: =IF(A2="MKT","Marketing",IF(A2="SLS","Sales", IF(A2="FIN","Finance",IF(A2="HR","Human Resources", IF(A2="OPS","Operations","Unknown")))))
The SWITCH version is 40% shorter and the cell reference (A2) appears exactly once. Adding a new department means adding one line — not editing two locations in a nested IF chain.

Example 2: Convert Weekday Numbers to Day Names

SWITCH pairs naturally with functions that return numeric codes. The WEEKDAY function returns 1–7 depending on the day of the week. SWITCH then maps those numbers to readable names. This combination works for MONTH (1–12), QUARTER, and any other function that produces a small set of numeric results.

2
Translate WEEKDAY numbers into day names and classify weekdays vs weekends
WEEKDAY returns 1 (Sun) to 7 (Sat) by default. SWITCH maps each number to its day name: =SWITCH(WEEKDAY(A2), 1, "Sunday", 2, "Monday", 3, "Tuesday", 4, "Wednesday", 5, "Thursday", 6, "Friday", 7, "Saturday") Classify as Weekday or Weekend using the same WEEKDAY result: WEEKDAY mode 2 returns 1 (Mon) to 7 (Sun) — Mon–Fri = 1–5, Sat–Sun = 6–7. =SWITCH(WEEKDAY(A2, 2)<=5, TRUE, "Weekday", FALSE, "Weekend") Notice: the expression evaluates to TRUE or FALSE, and SWITCH matches those values Month number to quarter label — same pattern with MONTH: =SWITCH(MONTH(A2), 1,"Q1", 2,"Q1", 3,"Q1", 4,"Q2", 5,"Q2", 6,"Q2", 7,"Q3", 8,"Q3", 9,"Q3", "Q4") ← October, November, December fall through to default
Multiple values can share the same result: When several months map to the same quarter, simply list each month value separately with the same result string — for example 1,"Q1", 2,"Q1", 3,"Q1". This is far cleaner than writing OR() conditions inside IFS.

Example 3: Use an Expression Inside SWITCH

SWITCH is not limited to simple cell references. Any formula that produces a single value works as the expression. This opens up range-based matching — something SWITCH does not support natively with operators. By evaluating the condition in the expression argument, you can effectively handle greater-than and less-than logic.

3
Classify values by range using an expression in the first argument
Use TRUE/FALSE matching to simulate range tests. The expression evaluates each condition in turn; SWITCH matches the first TRUE. =SWITCH(TRUE, B2>=90, "A", B2>=75, "B", B2>=60, "C", B2>=40, "D", "Fail") How it works: The first argument is the literal value TRUE. Each condition (B2>=90, B2>=75, ...) evaluates to TRUE or FALSE. SWITCH matches the first condition that equals TRUE — so it stops at the first passing test. The final "Fail" argument is the default (no value before it, so it catches all misses). Odd/even classification using MOD — expression returns 0 or 1: =SWITCH(MOD(A2, 2), 0, "Even", 1, "Odd")
The =SWITCH(TRUE, ...) pattern is a compact alternative to IFS. Both work identically for range tests. SWITCH(TRUE, ...) is slightly shorter because the expression "TRUE" replaces each repeated logical condition.

Example 4: Return a Calculation as the Result

Results in SWITCH do not have to be text strings or fixed values. Each result argument accepts any formula. Consequently, different branches of the SWITCH can apply completely different calculations — discount rates, multipliers, lookup formulas, or date offsets — based on the matched value.

4
Apply different discount rates per customer tier — results as formulas
A — Tier
B — Price
C — Discount %
D — Final price
Discount rate
Bronze
£200
5%
£190.00
× 0.95
Silver
£200
10%
£180.00
× 0.90
Gold
£200
15%
£170.00
× 0.85
Trial
£200
0%
£200.00
× 1.00
Each result is a formula using B2 (price). SWITCH picks the correct multiplier based on the tier in A2: =SWITCH(A2, "Bronze", B2 * 0.95, "Silver", B2 * 0.90, "Gold", B2 * 0.85, "Platinum", B2 * 0.75, B2) ← default: no discount for any other tier Return a lookup result as the SWITCH output — each tier maps to a different table row: =SWITCH(A2, "Bronze", VLOOKUP(B2, $E$2:$F$10, 2, 0), "Silver", VLOOKUP(B2, $G$2:$H$10, 2, 0), "NA")

Example 5: SWITCH as a Mini Lookup Table

For small, stable mapping sets, SWITCH is a lightweight alternative to VLOOKUP. It keeps the mapping inside the formula — no lookup table required. This is especially convenient for dashboards where adding a separate table would clutter the sheet.

When to Use SWITCH Instead of VLOOKUP

VLOOKUP is better for large or frequently changing mapping tables. SWITCH is better when the list is short, fixed, and unlikely to change — for instance, mapping 4 region codes or 5 status labels. Additionally, SWITCH avoids reference errors when the lookup table is on a different sheet that might be renamed or moved.

5
Map region codes to full region names — SWITCH as an inline lookup
Inline mapping — no lookup table needed. Region codes (N, S, E, W) expand to full region names: =SWITCH(A2, "N", "North", "S", "South", "E", "East", "W", "West", "Central", "Central", "Unknown region") VLOOKUP equivalent — requires an external table (E2:F6) on the sheet: =VLOOKUP(A2, $E$2:$F$6, 2, 0) Numeric status codes — map integers to status descriptions: =SWITCH(B2, 1, "Draft", 2, "Pending Approval", 3, "Approved", 4, "Rejected", 5, "Published", "Unknown status")
SWITCH is case-insensitive: It treats "N", "n", and "N" as identical matches. If case sensitivity matters — for example, when "N" and "n" should map to different results — use a different approach, such as EXACT() inside IFS.

Example 6: Handle Missing Matches with a Default Value

Without a default argument, SWITCH returns #N/A whenever the expression does not match any value. This error propagates through dependent formulas and breaks summaries. Adding a default — even an empty string — prevents this entirely. The default is always the final argument, with no value paired before it.

6
Control the no-match output — use a default instead of #N/A
Without a default — #N/A appears for any unrecognised code: =SWITCH(A2, "A", "Grade A", "B", "Grade B") If A2 = "C" → #N/A (no match, no default) With a text default — returns a readable message instead: =SWITCH(A2, "A", "Grade A", "B", "Grade B", "Grade not recognised") Empty string default — returns blank for no match (clean for dashboards): =SWITCH(A2, "A", "Grade A", "B", "Grade B", "") Zero default — useful when the SWITCH result feeds into a SUM: Returns 0 for no match, so SUM ignores the unmatched rows correctly. =SWITCH(A2, "Bronze", 0.05, "Silver", 0.10, "Gold", 0.15, 0) ← no discount for unrecognised tiers Wrap in IFERROR as an extra safety net: Catches any unexpected error, not just missing matches. IFERROR(=SWITCH(A2, "A", "Grade A", "B", "Grade B"), "Check value")
The default argument is the easiest way to handle missing cases. Choose the right default type for context: text for reports, empty string for dashboards, and zero for numeric results that feed into aggregate formulas.

How to Fix Common SWITCH Errors

#N/A — no match found

SWITCH returns #N/A when the expression does not equal any listed value and no default argument was provided. The fix is straightforward — add a default as the final argument. Even an empty string ("") stops the error from propagating. Alternatively, wrap the entire formula in IFERROR for a more general catch.

#VALUE! — mismatched value/result pairs

Every value must have a corresponding result. If you accidentally omit a result — for example, writing three values but only two results — Excel returns #VALUE!. Count the arguments carefully. Additionally, the default is intentionally an odd argument (unpaired), so it should always be the very last entry.

SWITCH returns the wrong result

The most likely cause is a type mismatch. SWITCH uses exact comparison, so the number 1 does not equal the text "1". To verify, use ISNUMBER or ISTEXT on the expression cell. Also check whether the expression produces leading or trailing spaces — in that case, TRIM the cell reference before using it in SWITCH.

SWITCH is not available in Excel 2016 or earlier: Formulas containing SWITCH produce a #NAME? error in these versions. For maximum compatibility, use IFS or nested IF instead. If you must use SWITCH, consider adding a note in the workbook that warns colleagues using older Excel installations.

Frequently Asked Questions

  • What is the SWITCH function in Excel?+
    SWITCH evaluates one expression — usually a cell reference — against a list of values and returns the result for the first match. It is a cleaner alternative to nested IF statements for exact value mapping. The expression appears just once, and each match/result pair follows in sequence. A final unpaired argument acts as the default when nothing matches.
  • What is the difference between SWITCH and IFS?+
    SWITCH compares one expression against exact values — for example, matching "MKT" to "Marketing". The expression is written once and must match exactly. IFS, by contrast, evaluates full logical conditions for each case — for example, B2>=90 — making it suitable for range-based tests. Use SWITCH when matching fixed values; use IFS when each condition involves a comparison operator.
  • How do I add a default value in SWITCH?+
    Add a single unpaired argument as the last entry in SWITCH. For example: =SWITCH(A2, "A", "Grade A", "B", "Grade B", "Not recognised"). The "Not recognised" text has no value before it, so Excel treats it as the default. Without this argument, SWITCH returns #N/A for any unmatched expression. Use "" for a blank result or 0 when the output feeds into a numeric formula.

More Questions About SWITCH

  • Can SWITCH handle greater-than and less-than comparisons?+
    Not directly — SWITCH only performs exact matching. However, you can work around this by using TRUE as the expression: =SWITCH(TRUE, B2>=90, "A", B2>=75, "B", "Fail"). Each condition evaluates to TRUE or FALSE, and SWITCH returns the result for the first condition that equals TRUE. This mimics the behaviour of IFS and is a useful technique when you prefer SWITCH's cleaner syntax.
  • How many conditions can SWITCH handle?+
    SWITCH accepts up to 126 value/result pairs, plus the optional default — making 253 arguments in total. In practice, however, formulas with more than ten or twelve pairs become difficult to read and maintain. For larger mapping tables, consider using VLOOKUP or XLOOKUP with a lookup range, which is easier to update without editing the formula itself.
  • Which Excel versions support SWITCH?+
    SWITCH is available in Excel 2019, Excel 2021, Excel 2024, and Microsoft 365. It is also supported in Excel for the web and Google Sheets. Notably, it is not available in Excel 2016 or earlier — formulas containing SWITCH produce a #NAME? error in those versions. For workbooks shared with colleagues on older Excel, use IFS or nested IF as a compatible alternative.