AnalystPracticeGuides
DashboardSign up

The Excel SWITCH function

SWITCH compares one value against a list of exact options and returns the result for the first match. It is cleaner than nested IF when you translate codes into names. It is available in Excel 2019, Excel 2021 and Microsoft 365.

What is the syntax?

=SWITCH(value, match1, result1, match2, result2, …, default) Turn region codes into names:

=SWITCH(A2,"N","North","S","South","E","East","Unknown")

The last argument without a pair is the default. Without it, an unknown code returns #N/A.

SWITCH or IFS?

SWITCH only checks for equality with one value. IFS can test any condition, such as B2>=90. Use SWITCH for codes and categories, IFS for ranges and mixed conditions.

A useful trick: SWITCH with TRUE

=SWITCH(TRUE,B2>=90,"A",B2>=75,"B","C")

This makes SWITCH behave like IFS. It works, but IFS is easier for others to read.

When is a lookup table better?

When the list of codes is long or changes. Keep the codes in a table and use XLOOKUP, so updating a name does not mean editing formulas.

Try it yourself. Practise this in a real spreadsheet in your browser, with instant feedback.
Practise SWITCH

Updated November 2026.

← All free guides