Ravindra BagaleCourses & study guides मराठी Track your progress

5. Data Cleaning A–Z

5.5 Inconsistent City Spellings

Fix city spellings with a mapping table with example — in 30 seconds

What: A small mapping table lists every wrong spelling and the one correct city name. A lookup replaces each raw value.

Why: Pune typed four ways becomes four rows in a PivotTable. One mapping table fixes this month and every month after.

Tiny example: " pune " and "Poona" both become Pune. "Kolapur" is not in the map, so it shows "CHECK: Kolapur".

First look at the data (before → after):

Fix city spellings with a mapping table with example: before and after tables, fictional FreshGo Maharashtra data

Expected result — Raw → clean city

B: Raw city C: Clean city
" pune " Pune
"Poona" Pune
"nasik" Nashik
"Sambhajinagar" Sambhaji Nagar
"Kolapur" CHECK: Kolapur

About this data: Teaching sample for a fictional shop “CityBasket Retail”. Figures and names (e.g. Neha Shah) are made up for this lesson on inconsistent city spellings.

Before table and formula as text

Before — Mapping table CityMap (lower case raw)

Raw Standard
pune Pune
poona Pune
nasik Nashik
nashik Nashik
sambhajinagar Sambhaji Nagar

About this data: Demo table only — not real customer or company data. Built to practise inconsistent city spellings.

Formula / click path

C2: =XLOOKUP(LOWER(TRIM(B2)), CityMap[Raw], CityMap[Standard], "CHECK: "&B2)

Do it step by step:

  1. Make a table named CityMap with columns Raw (lower case) and Standard.
  2. In C2, type the formula shown above.
  3. LOWER and TRIM clean the raw text before the lookup.
  4. Copy down. Filter column C for "CHECK:".
  5. Add each new spelling to CityMap. The CHECK rows fix themselves.

The same city is typed in many ways. Aurangabad was officially renamed Chhatrapati Sambhaji Nagar; our standard spelling in this book is Sambhaji Nagar.

Before

Order ID City (raw)
BLK-3101 pune
BLK-3102 PUNE
BLK-3103 Pune City
AMN-3104 Aurangabad
AMN-3105 Chh. Sambhajinagar
BLK-3106 Nasik
BLK-3107 Kolhapur
BLK-3108 Sholapur

About this data: Made-up rows so you can copy the pattern for inconsistent city spellings. Currencies may use ₹, £, € or $.

After

Order ID City
BLK-3101 Pune
BLK-3102 Pune
BLK-3103 Pune
AMN-3104 Sambhaji Nagar
AMN-3105 Sambhaji Nagar
BLK-3106 Nashik
BLK-3107 Kolhapur
BLK-3108 Solapur

About this data: Fictional worksheet used in class. Safe to edit; nothing here is live production data.

Method 1 – Find & Replace (few variants)

Steps in Excel

  1. Select the City column › Home › Editing › Find & Select › Replace (Ctrl + H).
  2. Find Aurangabad › Replace with Sambhaji Nagar › Options » › tick Match entire cell contents › Replace All.
  3. Repeat for Nasik → Nashik, Sholapur → Solapur, Pune City → Pune.
  4. Finish with =PROPER(TRIM(B2)) for case and spaces.

Method 2 – mapping table (many variants, repeatable)

Create a Table CityMap on a Lists sheet:

Raw (lower case, trimmed) Standard
pune Pune
pune city Pune
aurangabad Sambhaji Nagar
chh. sambhajinagar Sambhaji Nagar
chhatrapati sambhaji nagar Sambhaji Nagar
nasik Nashik
sholapur Solapur
kolhapur Kolhapur

About this data: Teaching sample for a fictional shop “CityBasket Retail”. Figures and names (e.g. Neha Shah) are made up for this lesson on inconsistent city spellings.

Then in the data:

=XLOOKUP(LOWER(TRIM(B2)), CityMap[Raw], CityMap[Standard], "CHECK: "&B2)

Anything new shows "CHECK: …" so you can add it to the map. (Older Excel: =IFNA(VLOOKUP(LOWER(TRIM(B2)),CityMap,2,FALSE),"CHECK: "&B2).)

Ravindra Bagale's Tip

If Match entire cell contents is not ticked in Find & Replace, many students end up with a mess: while replacing "Pune", "Pune City" becomes "Pune City City". Always tick it. For data that comes every day, a mapping table is best – once it's built, a new spelling can be fixed just by adding one row.

Practice task

Build a CityMap for at least 12 spellings of our six cities (include Aurangabad, Nasik, Sholapur, Kolhapur with a trailing space). Apply it and make sure no "CHECK:" rows remain.

Loading practice tasks...

  1. Correct name for C2 (Easy): Find the correct city for C2 using CityMap.
  2. Correct name with VLOOKUP (Easy): Find the correct city for C4 with VLOOKUP.
  3. Correct name for C6 (Easy): Find the correct city for C6.
  4. Correct name for C8 (Easy): Find the correct city for C8.
  5. Fix the extra space first (Medium): Find the correct city for C3. Clean it first.
  6. Name not in the list (Medium): For C9 show the correct city, or "CHECK: Gurgaon" if not found.
  7. IFNA with VLOOKUP (Medium): For C9 use VLOOKUP, and show "CHECK" if not found.
  8. Is the name already correct? (Medium): Is C2 already the correct name? (TRUE or FALSE)
  9. Amount for Mumbai (both names) (Hard): Total amount for Bombay plus Mumbai (use TRIM so "Mumbai " counts).
  10. Amount for Bengaluru (both names) (Hard): Total amount for Bangalore plus Bengaluru.

Quick revision cards

Three standalone cards. Each one explains the idea with its own example. Scan the QR to open this lesson.

Revision card 1: What is Inconsistent City Spellings?
Card 1: What is Inconsistent City Spellings? · Download PNG
Revision card 2: Tiny example — Inconsistent City Spellings
Card 2: Tiny example — Inconsistent City Spellings · Download PNG
Revision card 3: Checklist — Inconsistent City Spellings
Card 3: Checklist — Inconsistent City Spellings · Download PNG