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

26. Excel Tricks Every Analyst Should Know

26.2 Data Cleaning Tricks

Example first. An export has extra spaces, amounts stored as text, repeated Order IDs and City and PIN in one cell. Four quick fixes make it usable.

Trick 5. Remove extra spaces with TRIM is shown in the box below; tricks 6–8 follow it.

TRIM for extra spaces — in 30 seconds

What: TRIM removes spaces at the start and end of text and turns double spaces inside into single spaces.

Why: "Pune " and "Pune" look the same but do not match in SUMIFS, XLOOKUP or a PivotTable. TRIM makes them equal.

Tiny example: LEN(" Pune ") is 7; LEN(TRIM(" Pune ")) is 4. "Nashik Road" becomes "Nashik Road".

First look at the data (before → after):

TRIM for extra spaces: before and after tables, fictional Blinkit Maharashtra data

Expected result — After =TRIM(A2)

B: Clean city LEN(B)
Pune 4
Nashik Road 11
Kolhapur 8
Before table and formula as text

Before — Imported text (spaces shown as ·)

A: City LEN(A)
··Pune· 7
Nashik··Road 12
·Kolhapur 9

Formula / click path

B2: =TRIM(A2)
C2: =LEN(B2)

Do it step by step:

  1. In B2 type =TRIM(A2) and fill down.
  2. Check with =LEN(B2): the number drops.
  3. Copy column B and Paste Values over column A, then delete column B.

Trick 6. Turn numbers stored as text into numbers

Before:

A: Amount (text) Note
450 left-aligned, green triangle
120 left-aligned, green triangle
95 left-aligned, green triangle
=SUM(A2:A4) 0

After:

B: Amount —
450 —
120 —
95 —
=SUM(B2:B4) 665
B2: =VALUE(A2)
B5: =SUM(B2:B4)  → 665

Steps:

  1. In B2 type =VALUE(A2) and fill down; or select A2:A4, click the green-triangle warning and choose Convert to Number.
  2. Total with =SUM(B2:B4).
  3. Paste the values back over column A if you need them there.

Trick 7. Remove duplicate rows

Before:

A: Order ID
BLK-1001
BLK-1002
BLK-1001
AMN-1003
BLK-1002
AMN-1005

After:

A: Order ID
BLK-1001
BLK-1002
AMN-1003
AMN-1005

Steps:

  1. Click inside the list.
  2. Click Data › Data Tools › Remove Duplicates.
  3. Tick the column(s) that define a duplicate and click OK.
  4. Excel reports: 2 duplicate values removed; 4 unique values remain.
  5. Work on a copy: Remove Duplicates deletes rows.

Trick 8. Split one column into two with Text to Columns

Before:

A: Location
Pune-411001
Nashik-422001
Nagpur-440001

After:

A: City B: PIN
Pune 411001
Nashik 422001
Nagpur 440001

Steps:

  1. Select A1:A3 (make sure column B is empty).
  2. Click Data › Data Tools › Text to Columns › Delimited › Next.
  3. Tick Other and type -, click Next.
  4. Set column B to Text so the PIN keeps every digit, and click Finish.

Practice task (try it before you open the answer):

  1. Convert "450", "120", "95" (text) to numbers and total them.
  2. Remove duplicates from the 6 Order IDs.
  3. Split "Nashik-422001" into City and PIN.
Answer

VALUE gives 450, 120, 95; total 665 (the text version totals 0). Remove Duplicates keeps 4 IDs. Text to Columns with "-" gives Nashik and 422001 (set the PIN column to Text).

Ravindra Bagale's Tip

When a SUM is smaller than you expect, select the column and look at the status bar: if Count is bigger than Sum can explain, some numbers are text.

Loading practice tasks...

  1. Clean a name (Easy): Clean A2.
  2. Clean another name (Easy): Clean A4.
  3. Yes/No in one style (Easy): Clean D4 into proper case.
  4. Fee as a number (Easy): Change C2 into a number.
  5. Phone digits only (Medium): Clean E3.
  6. Paid as TRUE/FALSE (Medium): Is D4 a yes? (TRUE or FALSE)
  7. How many paid? (Medium): Count D2:D6 that are "yes" after cleaning.
  8. Total fees (Medium): Total of C2:C6 as numbers.
  9. Fees not yet paid (Hard): Total fee where Paid is "no" after cleaning.
  10. Reminder line (Hard): Make "Naina Kapoor (9-B): pay 21000" from row 3.
  11. Unpaid students (spill) (Hard): Cleaned names where Paid is "no".