Excel functions / Logical

SWITCH

Compares one value against a list of exact matches and returns the matching result.

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

Arguments

expressionThe value to check, often a cell.
value, result pairsEach possible match and what to return for it.
defaultOptional. A final, unpaired result for when nothing matches.

How it works

SWITCH is the neat choice when you are translating codes: N to North, 1 to Monday, Yes to Present. You write the value once instead of repeating it in every test.

It only matches exact values. For ranges, such as scores of 60 or more, use IFS.

Example

E2=SWITCH(C2,"Yes","Present","No","Absent","Unknown")
ABCDE
1StudentScoreAttended
2Ana72YesPresent
3Ben45Yes
4Cal88No
5

Result: Present. C2 is Yes, so the result for Yes is returned.

Tips

Practise SWITCH

Try it yourself in a real spreadsheet, with instant feedback on every answer.

Start the exercise

Related