Skip to content
GridBelt
  • Excel Test
  • Practice
  • Programs
  • Pricing
Sign in
Start the free test
  • Excel Test
  • Practice
  • Programs
  • Pricing
Sign inCreate account
Start the free test
GridBelt

Practice Excel in your browser.

Excel Test

  • Level 1: Beginner
  • Level 2: Intermediate
  • Level 3: Expert
  • Excel test in 7 days
  • Leaderboard
  • Excel test for interview
  • Indeed Excel assessment

Practice

  • All exercises
  • Programs
  • For beginners

Guides

  • Excel formulas
  • Excel shortcuts

Company

  • About
  • Pricing
  • How we grade

© GridBelt. All rights reserved.

  • Privacy Policy
  • Terms of Use
  • Refund Policy

Excel is a trademark of Microsoft Corporation. Indeed, TestGorilla, SHL and other marks are the property of their owners. GridBelt is an independent practice site and is not affiliated with, endorsed by or sponsored by Microsoft, TestGorilla, SHL or Indeed.

  1. Practice
  2. /
  3. IF function

SWITCH and IFS practice: region names from codes on 200 shipments

  • Expert
  • ~8 min
  • IF function

The warehouse system exports 200 October shipments with a one-letter region code in column B: N, S, E, W and C stand for North, South, East, West and Central. The dashboard needs the full names, and 6 rows carry codes the mapping does not know — a blank, a typo like "NE" — which must read Unknown rather than an error, so they can be sent back for correction. Translate the codes with one formula.

What you need to do

  1. 1Click F2. The code to translate is in B2.
  2. 2Type =SWITCH(B2, then list the pairs code, name — "N","North","S","South","E","East","W","West","C","Central" — and finish with the default "Unknown" as the last argument before the closing bracket.
  3. 3Press Enter and fill F2 down to F201 (double-click the fill handle, or select F2:F201 and press Ctrl+D / ⌘D).
  4. 4Find a row with an unknown code (an empty code or "NE"): it must read Unknown. Then click Check (Ctrl+Enter / ⌘+Return). IFS with a TRUE,"Unknown" catch-all is accepted as well.

Answer cells

Feedback

Type your formula in the grid, press Enter, then Check. We grade the value in each answer cell and the formula behind it.

Tasks

  1. Not checkedIn F2, return the region name for the code in B2 — N North, S South, E East, W West, C Central, anything else "Unknown" — with SWITCH or IFS, then fill it down to F201.

Desktop recommended for spreadsheet tasks. The sheet scrolls inside this box.

StartInsertFormulasDataView
A1fxPreparing your workbook…
A
B
C
D
E
F
G
H
I
J
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Sheet1

Enter your formula in the sheet, then check.

About this exercise

A 200-row dataset on one sheet, one answer cell, about 8 minutes. Graded in your browser: the value and the formula behind it, with feedback that names the fix.

How to solve it

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

SWITCH takes one expression — the code in B2 — and a list of value/result pairs: when the code equals "N" it returns "North", when it equals "S" it returns "South", and so on. An odd final argument is the default, returned when nothing matched, which is how the blank and mistyped codes become Unknown instead of an error. IFS does the same with explicit tests (B2="N", B2="S", …) and a TRUE,"Unknown" pair at the end; both read far better than four nested IFs.

Pitfall 1: forgetting the default — SWITCH without it returns #N/A for the unmapped codes, and IFS without the TRUE branch does the same, which then poisons every COUNTIF and pivot built on the column. Pitfall 2: SWITCH only tests equality against one expression; for ranges (>=) you need IFS or a lookup. Comparisons are case-insensitive ("n" matches "N") but a trailing space in the code is a different value — TRIM(B2) when the export is dirty. Pitfall 3: a mapping typed into a formula is hidden from the people who maintain the codes; once the list has more than a handful of entries, put it in a two-column table and use XLOOKUP(B2,codes,names,"Unknown") or VLOOKUP with IFERROR. Version notes: SWITCH and IFS exist in Excel 2019, 365 and the web app; in Excel 2016 and earlier use nested IF or CHOOSE(MATCH(B2,{"N","S","E","W","C"},0),…) wrapped in IFERROR. Performance: all variants are trivial at 200 rows; the lookup version is also the fastest to recalculate once the sheet grows to hundreds of thousands of rows.

Other ways that work

  • =IFS(B2="N","North",B2="S","South",B2="E","East",B2="W","West",B2="C","Central",TRUE,"Unknown") — IFS with a catch-all TRUE branch
  • =IFERROR(XLOOKUP(B2,{"N","S","E","W","C"},{"North","South","East","West","Central"}),"Unknown") — Excel 365; a lookup against inline arrays (not accepted by this task, which asks for SWITCH or IFS)
  • =IF(B2="N","North",IF(B2="S","South",IF(B2="E","East",IF(B2="W","West",IF(B2="C","Central","Unknown"))))) — the nested-IF version this exercise replaces

Common mistakes

Leaving out the default value: =SWITCH(B2,"N","North",…,"C","Central") returns #N/A on the 6 rows with an unknown code, and the first of those is the cell the grader names.

How we grade

Any formula that produces the right result is accepted, unless the task names a function: then another function earns half credit. We compare values with a small tolerance and ignore case and spaces in text. A correct number typed by hand instead of a formula earns half credit. Multi-cell tasks earn full credit at 100% of cells, half credit from 50%. Where it matters, we also change an input cell on a copy of your sheet and check that your formula follows.

Answers computed with Excel 365 rules and checked in our grading engine on November 16, 2026. Author: GridBelt team.

In these programs

  • Excel for Data AnalystsDay 10

Related exercises

  • Commission tiers with nested IF, IFS or a lookupIntermediate, ~8 min
  • Pass or Fail with IFBeginner, ~4 min
  • Orders per region and month with COUNTIFSIntermediate, ~7 min

Function reference

Official documentation

Next exercise

Orders per status with COUNTIF