String Cleansing, Normalization & Merging: TRIM, CLEAN, TEXTJOIN
Overview & Learning Objectives
Messy data exports from ERP systems arrive full of rogue line breaks, trailing spaces, and inconsistent casing. Normalizing strings with TRIM, CLEAN, PROPER, and merging them with TEXTJOIN builds clean customer databases.
- Remove invisible ASCII characters and irregular spacing with TRIM and CLEAN.
- Standardize names into proper title casing with PROPER.
- Concatenate multi-column address fields with TEXTJOIN, safely skipping empty cells.
Industry Standard
Standard: E-commerce dispatch hubs at Flipkart and Amazon standardize shipping label addresses into single-line formats using TEXTJOIN with comma delimiters.
Real-World Example: E-Commerce Address Concatenation & Data Normalization
At QuickShip Logistics, delivery addresses arrive across 4 separate columns: Flat No, Street, City, and Pincode. Some rows lack Flat No. TEXTJOIN merges them with clean commas while automatically skipping empty cells.
| Flat / House | Street | City | Pincode | Combined Clean Address |
|---|---|---|---|---|
| Flat 402 | Green Glen Layout | Bangalore | 560103 | Flat 402, Green Glen Layout, Bangalore, 560103 |
| MG Road | Bangalore | 560001 | MG Road, Bangalore, 560001 (skips blank) | |
| Plot 12 | Banjara Hills | Hyderabad | 500034 | Plot 12, Banjara Hills, Hyderabad, 500034 |
Functions Covered in this Chapter
Here is the definition, exact syntax, parameter breakdown, and real-world business example for each function covered in this chapter:
TRIM Function
Definition: Removes all leading spaces, trailing spaces, and redundant double spaces from text, leaving only single spaces between words.
=TRIM(text)
text: The cell containing text with irregular spacing.
=TRIM(" Rohit Sharma ")CLEAN Function
Definition: Removes all non-printable ASCII characters (ASCII codes 0 through 31, including line breaks and tabs) imported from database exports.
=CLEAN(text)
text: The text containing line breaks or unprintable characters.
=CLEAN(A2)TEXTJOIN Function
Definition: Combines the text from multiple ranges and/or strings, using a specified delimiter between each text item, with an option to ignore empty cells.
=TEXTJOIN(delimiter, ignore_empty, text1, [text2], ...)
delimiter: The separator string placed between items (e.g. ", " or " - ").ignore_empty: TRUE ignores blank cells; FALSE includes empty delimiters.text1, [text2]: The strings or cell ranges to join (e.g. A2:D2).
=TEXTJOIN(", ", TRUE, A2:D2)PROPER Function
Definition: Capitalizes the first letter of every word in a text string and converts all other letters to lowercase.
=PROPER(text)
text: The text string to convert to title case.
=PROPER("sAcHiN gArG")Common Mistakes & Limitations
- Assuming TRIM removes the non-breaking space character (`CHAR(160)`) common in web scraped data. Use `=TRIM(CLEAN(SUBSTITUTE(A2, CHAR(160), " ")))` for bulletproof cleaning.
- Using old `CONCATENATE()` which does not support ranges and cannot automatically ignore blank cells.
Keyboard Shortcuts
| Action | Windows | Mac |
|---|---|---|
| Uppercase / Lowercase (Word toggle) | Shift + F3 inside Word | Shift + F3 |
| Flash Fill Pattern Recognition | Ctrl + E | Ctrl + E |
Pro Tips & Modern Alternatives
- Power Query -> Transform -> Format -> Capitalize Each Word & Trim provides 1-click batch cleanup for 100,000+ rows.
- Use `&` operator (`=A2 & " " & B2`) for simple two-cell joins.