The SWITCH function

Compares one value against a list and returns the result for the first match, with an optional default at the end.

Syntax

SWITCH(expression, value1, result1, [value2, result2], ..., [default])
expression
The value to compare.
value1, result1
A value to match and the result to return for it.
default (optional)
What to return when nothing matches. Without it SWITCH returns #N/A.

Examples

C1=SWITCH(A2,"DK","Denmark","SE","Sweden","Other")
ABC
1CodeDenmark
2DK

In plain words: Look at the code in A2: if it is DK, show Denmark; if it is SE, show Sweden; otherwise show Other.

C1=SWITCH(A2,"NO","Norway","Other")
ABC
1CodeOther
2DK

Read the guide

Related functions