You receive customer data exported from different systems. Some names have extra spaces, some cities are in all caps, and customer codes contain useful city and ID information. Text Functions help you clean and reshape the data before reporting.
Clean text with TRIM and PROPER
TRIM removes unnecessary extra spaces. PROPER capitalizes each word. These are often the first formulas you should use on messy imported data.
Before and after cleaning
| Raw Value | Formula | Clean Output |
|---|---|---|
| aarav traders | =PROPER(TRIM(A2)) | Aarav Traders |
| AHMEDABAD | =PROPER(TRIM(A2)) | Ahmedabad |
Extract text with LEFT, RIGHT and MID
When codes follow a consistent pattern, you can extract useful parts from them. For example, from CUST-AHD-1001, you can extract AHD as city code and 1001 as customer number.
Join text and extract email domain
You can join text using the & operator. Example: =B2&" - "&C2 creates a display name like Aarav Traders - Ahmedabad.
You can also combine RIGHT, LEN and FIND to extract the email domain after the @ symbol.
=CustomerName&" - "&City=RIGHT(Email,LEN(Email)-FIND("@",Email))=PROPER(TRIM(City))=RIGHT(CustomerCode,4)Interview question
Question: Which text functions are most useful for cleaning imported Excel data?
Answer: TRIM for extra spaces, PROPER or UPPER for text case, LEFT/RIGHT/MID for extracting code parts, LEN for length checks, FIND for locating characters, and & or TEXTJOIN for combining text.
Clean customer data using Text Functions
Download one ZIP file containing the practice workbook, challenge workbook, solution workbook, formula cheat sheet, quiz and answer key.
Mini assignment
- Use TRIM to clean Customer Code.
- Use PROPER and TRIM to clean Customer Name and City.
- Use MID to extract City Code.
- Use RIGHT to extract Customer Number and Order Number.
- Use FIND and RIGHT to extract Email Domain.
- Use & to create Display Name.
Quick quiz
- Which function removes extra spaces?
- Which function capitalizes each word?
- Which function extracts text from the middle?
- How do you join two text values?
Answers: TRIM; PROPER; MID; use & or TEXTJOIN.