Maintenance Notification: We are upgrading our servers today so you may experience intermediate outages. Thank you for your patience.
Perform logical operations in formulas
MO-211

Perform logical operations by using the SWITCH() function

=SWITCH(B2, "N", "North", "S", "South", "E", "East", "W", "West", "Unknown")

Compare B2 with each case in turn and return the result beside the first exact match. The last, unpaired value is the default.

What the MO-211 task asks

SWITCH fits a task that maps codes to labels. In our MO-211 practice exams it reads like “set each film's price band from its Certificate: U and PG pay Family, 12A and 15 pay Standard, 18 pays Late. Anything else falls back to Standard.” A list of exact values, each with a result, and a fallback, is SWITCH.

“Anything else falls back to” is the default: one extra value at the end with no case in front of it. SWITCH only matches exactly, so a band such as “12 or more” is an IFS task, not a SWITCH one.

Our grader checks the value in every cell of the target range. It reads the values, not the function, so any formula that produces them earns the points — but one wrong cell fails the whole range.

Worked examples

Type these into a blank sheet to follow along. Every result below is what Excel showed.

Shipments (the video fills C2:C6)
ABC
1ShipmentCodeRegion
2R-1NNorth
3R-2EEast
4R-3WWest
5R-4XUnknown
6R-5SSouth
Tickets
EF
1TicketPriority
2T-12
3T-21
4T-33
An exact case
=SWITCH(B3, "N", "North", "S", "South", "E", "East", "W", "West", "Unknown")
Returns East

B3 holds E, the third case, so SWITCH returns the value paired with it.

No default
=SWITCH(B5, "N", "North", "S", "South", "E", "East", "W", "West")
Returns #N/A

X matches no case, and without a default there is nothing to return.

Numbers as cases
=SWITCH(F3, 1, "High", 2, "Medium", 3, "Low")
Returns High

The cases can be numbers. F3 holds 1, so the ticket is High.

Two cases, one result
=SWITCH(B2, "N", "Cold", "S", "Warm", "E", "Warm", "Mild")
Returns Cold

A result can appear more than once; each case still needs its own pair.

Filled down a column
=SWITCH(B2, "N", "North", "S", "South", "E", "East", "W", "West", "Unknown")
Returns North, East, West, Unknown, South in C2:C6

The default catches R-4's code X. This is what the video below builds.

Watch it done in Excel

The last example above, recorded in real Excel on the same grid.

Exam traps

Forgetting the default

“Anything else falls back to Standard” is the last, unpaired value. Leave it out and every code not in the list shows #N/A, as R-4 does with =SWITCH(B5, "N", "North", "S", "South", "E", "East", "W", "West").

Using SWITCH for a range of values

SWITCH compares for equality only. =SWITCH(F4, ">2", "Low", "Other") returns Other for a priority of 3: it looked for the text >2. Bands are an IFS task.

A number case written as text

=SWITCH(F3, "1", "High", "Other") returns Other, because F3 holds the number 1 and "1" is text. Write number cases without quotes.

Mixing up the order of the pairs

Each pair is the case, then its result. =SWITCH(B2, "North", "N", "Unknown") returns Unknown for N: it was looking for the word North.

FAQ

Is SWITCH case-sensitive?

No. =SWITCH("n", "N", "North", "Unknown") returns North.

SWITCH or IFS?

SWITCH when one value is compared with exact cases, as with codes. IFS when each band is a comparison such as >= 20.

Can the default be a number?

Yes. =SWITCH(F2, 1, 10, 2, 5, 0) returns 5 for priority 2, and 0 for any priority not listed.

New to this function?

This page covers what the exam asks. For the full how-to — every argument, more examples and a practice workbook — read our guide on dfwexcel.com.

The SWITCH function, explained — dfwexcel.com

Try it under exam conditions

Take a full, timed MO-211 practice exam, upload the workbook you built, and get a score out of 1000 with a per-task breakdown of where the points went. Your first one is free.

No credit card needed.