Explanation

SWITCH compares an expression/value with several possible values and returns the corresponding result.

Syntax

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

Example — Employee Department

Code

Department

1

Sales

2

HR

3

IT

4

Accounts

Formula

=SWITCH(B2,1,”Sales”,2,”HR”,3,”IT”,4,”Accounts”,”Unknown”)

Result

If B2 = 3:

IT

When to Use SWITCH?

Use SWITCH when you have fixed values/codes and each value has a different result.

Practice

Create a department code system:

1 → Sales
2 → HR
3 → IT
4 → Accounts
5 → Marketing