Turn codes into names with SWITCH
PremiumIn C2, use SWITCH to turn the code in B2 into a name: "N" is "North", "S" is "South", and any other code is "Other".
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Order | Region code | Region | |||
| 2 | 1042 | S | ||||
| 3 | ||||||
| 4 | ||||||
| 5 | ||||||
| 6 | ||||||
| 7 | ||||||
| 8 |
Premium lesson
Unlock IFS and SWITCH and every other lesson
This is a premium lesson. Premium lets you solve it and every other lesson, take the timed mock tests, and earn certificates you can share on LinkedIn.
Your first month for $9.50 $19
50% off your first month when you join today.
Then $19/month. Cancel any time, and get a full refund within 14 days if it isn't for you.
Why this works
SWITCH compares B2 with each value in turn: "N" does not match, "S" does, so it returns "South". The last argument has no value before it, so it is the default for every other code. Without it, an unknown code gives #N/A.
Common mistake: Writing tests like B2="N" inside SWITCH. SWITCH does the comparing itself; it wants the value, "N".
The answer
- C2
=SWITCH(1B2,2"N",3"North",4"S",5"South",6"Other")
In plain words: Look at 1the code in B2: 2N gives 3North, 4S gives 5South, and 6any other code gives Other.