Building and Cleaning: Putting It Together
About this lesson
Cleaning imported text usually means four things. Trim the spaces, fix the case, replace the separators, and convert anything numeric back into a number.
- clean an imported column with TRIM, SUBSTITUTE, PROPER and VALUE.
- build a label from several cells with & and TEXT.
The idea
The order matters less than doing all four. But trim first. It removes the thing that stops values matching, and everything after it is easier to check. Functions nest from the inside out, so the one written innermost runs first.
The part people skip is checking. Cleaning is invisible work. The cell looked fine before and looks fine after. So it is entirely possible to apply TRIM to the wrong column and never find out. Comparing a length before and after, or asking ISNUMBER whether a conversion really converted, takes one formula. It turns a belief into a fact. Every cleaning step in this module has a matching check, and the check is the half to keep on the sheet.
The mistake to watch for
Cleaning without checking. The cell looked fine before and looks fine after. So TRIM applied to the wrong column, or a conversion that never converted, is invisible. Compare a length before and after, or ask ISNUMBER whether the number is now a number. One formula turns a belief that the cleaning worked into a fact.
Where this comes up again
This lesson needs JavaScript to run. Everything below is the lesson in full, but you cannot type into the grid or be marked.
The supplier name in A2 arrived with spaces around it and no capitals. In B2, fix both at once.
To begin, type it exactly:
=PROPER(TRIM(A2))
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Raw | Cleaned | Check | ||||
| 2 | ashworth & co | ||||||
| 3 | PO/2024/0417 | ||||||
| 4 | 0088 | ||||||
| 5 | Dilys | Pritchard | |||||
| 6 | |||||||
| 7 | |||||||
| 8 |
Every step
-
The supplier name in
A2arrived with spaces around it and no capitals. InB2, fix both at once. To begin, type it exactly:=PROPER(TRIM(A2)). -
In
B3, rewrite the purchase order inA3with hyphens instead of slashes. -
B4was meant to turn the imported reference inA4into a number and add one to it. It does no converting at all. Repair it. -
In
C5, build a full name fromA5andB5with a space between them. UseCONCAT. -
Check the tidying worked. Read
=LEN(TRIM(A2))and say what it returns. -
One last conversion. In
C3, show the length of the rewritten purchase order as text with no decimal places.