মূল বিষয়বস্তুতে যান
LogicalIntermediate LevelIntermediate Excel (Lookups & Business Analytics)

How to Use SWITCH in Excel

Replaces long chains of nested IF with one readable list of value-and-result pairs.

Direct Answer (Quick Summary)

What is SWITCH in Microsoft Excel?

SWITCH evaluates an expression once and compares it against a list of values, returning the matching result. It is cleaner than IF(A2="A",...,IF(A2="B",...)) because the expression appears only once and each case sits on its own line. A final argument acts as the default when nothing matches.

Pro Tip: Always add the default argument. Without it, an unmatched value returns #N/A, which is easy to miss until a new code appears in next month's data.

Formula Syntax

=SWITCH(expression, value1, result1, value2, result2, , default)

Arguments Breakdown

ArgumentRequirementPurpose & Details
expressionRequiredThe value or formula to test, evaluated only once.
value1RequiredThe first value to compare against the expression.
result1RequiredWhat to return when expression equals value1.
defaultOptionalAn optional final value returned when nothing matches.

When to Use SWITCH (Real-World Business Scenarios)

  • 1

    Mapping short codes to full labels, such as department codes to department names.

  • 2

    Converting a numeric grade to a letter grade with five or six bands.

  • 3

    Cleaning imported status values like 'D', 'P', 'C' into Delivered, Pending and Cancelled.

Step-by-Step Practical Business Example

Suppose you have the following dataset in Excel cells A1:D4:

CodeDepartment
FINFinance
MKTMarketing
ENGEngineering
Applied Formula:Result: Finance
=SWITCH(A2,"FIN","Finance","MKT","Marketing","ENG","Engineering","Other")

How it works: Compares A2 against each listed code and returns the matching label. Any unknown code falls through to 'Other'.

Common Errors & How to Fix Them

#N/A

Why it happens: No value matched and no default argument was supplied.

Fix: Add a final default value: =SWITCH(A2,"FIN","Finance","Other").

Wrong branch taken

Why it happens: The pairs were supplied in the wrong order, so a value and its result are swapped.

Fix: Remember the pattern is value, result, value, result. Count the arguments to confirm each pair is complete.

Interactive Formula Lab

Try SWITCH Live in Your Browser

No need to launch desktop Excel. Practice formulas with real-time feedback in our HyperFormula sandbox.

Open Practice Lab

Frequently Asked Questions (SWITCH)

What does the SWITCH formula do in Excel?

SWITCH evaluates an expression once and compares it against a list of values, returning the matching result. It is cleaner than IF(A2="A",...,IF(A2="B",...)) because the expression appears only once and each case sits on its own line. A final argument acts as the default when nothing matches.

What is the syntax for SWITCH?
=SWITCH(expression, value1, result1, value2, result2, , default)
What are common mistakes when using SWITCH?

#N/A: No value matched and no default argument was supplied. (Add a final default value: =SWITCH(A2,"FIN","Finance","Other").) Wrong branch taken: The pairs were supplied in the wrong order, so a value and its result are swapped. (Remember the pattern is value, result, value, result. Count the arguments to confirm each pair is complete.)

Keep building your formula toolkit with these logical functions.

Browse all 41 Excel formulas
Ready to Master Microsoft Excel?

Master SWITCH in Intermediate Excel

Learn SWITCH along with our formula library, practice files, and verifiable certificates in our complete curriculum.

Strictly necessary