Bird
Raised Fist0
Power BIbi_tool~5 mins

Trim and clean text in Power BI - Step-by-Step Guide

Choose your learning style10 modes available
Introduction
This feature helps you remove extra spaces and unwanted characters from text data. It makes your text clean and neat for better analysis and display in reports.
When your sales data has extra spaces before or after product names that cause mismatches.
When customer feedback contains hidden line breaks or tabs that affect text filters.
When you want to standardize addresses by removing extra spaces and non-printable characters.
When importing data from Excel or CSV files that include irregular spacing.
When preparing text fields for joining tables or creating slicers.
Steps
Step 1: Click
- Modeling tab
The ribbon shows options to create new columns or measures
Step 2: Click
- New column
A formula bar appears to write a DAX expression for the new column
Step 3: Type
- Formula bar
You enter a formula using TRIM and CLEAN functions to clean text
💡 Use syntax: CleanedText = TRIM(CLEAN(TableName[ColumnName]))
Step 4: Press Enter
- Formula bar
A new column appears in the data view with cleaned and trimmed text
Step 5: Use
- Report view
The cleaned text column can be used in visuals and slicers without extra spaces or hidden characters
Before vs After
Before
Column 'Product' has values like ' Apple ', 'Banana\n', and ' Orange\t'
After
New column 'CleanedText' shows 'Apple', 'Banana', and 'Orange' without extra spaces or hidden characters
Settings Reference
TRIM function
📍 DAX formula bar
To remove extra spaces before, after, and between words
Default: N/A
CLEAN function
📍 DAX formula bar
To remove hidden characters that can cause display or filtering issues
Default: N/A
Common Mistakes
Using only TRIM without CLEAN
TRIM removes extra spaces but does not remove hidden characters like line breaks
Use CLEAN inside TRIM like TRIM(CLEAN(Column)) to remove both spaces and hidden characters
Applying TRIM and CLEAN on numeric columns
These functions work on text data and can cause errors or unexpected results on numbers
Convert numbers to text first if cleaning is needed, or apply only on text columns
Summary
Trim and clean text removes extra spaces and hidden characters from text data.
Use TRIM to remove extra spaces and CLEAN to remove non-printable characters.
Apply these functions in a new column using DAX for clean, consistent text in reports.

Practice

(1/5)
1. What does the TRIM function do in Power BI?
easy
A. Removes all numbers from text
B. Removes extra spaces from the start and end of text
C. Converts text to uppercase
D. Removes punctuation marks from text

Solution

  1. Step 1: Understand the purpose of TRIM

    The TRIM function removes extra spaces from the start and end of a text string, making it neat.
  2. Step 2: Compare with other options

    Options A, C, and D describe different text operations not related to trimming spaces.
  3. Final Answer:

    Removes extra spaces from the start and end of text -> Option B
  4. Quick Check:

    TRIM removes spaces = B [OK]
Hint: TRIM cleans spaces around text, not inside [OK]
Common Mistakes:
  • Thinking TRIM removes spaces inside text
  • Confusing TRIM with CLEAN
  • Assuming TRIM changes text case
2. Which of the following is the correct syntax to remove non-printable characters from a column named Comments in Power BI?
easy
A. REMOVE(Comments)
B. TRIM(Comments)
C. STRIP(Comments)
D. CLEAN(Comments)

Solution

  1. Step 1: Identify the function for non-printable characters

    The CLEAN function removes hidden non-printable characters from text.
  2. Step 2: Verify syntax correctness

    CLEAN(Comments) is the correct syntax; TRIM removes spaces, REMOVE and STRIP are invalid in Power BI.
  3. Final Answer:

    CLEAN(Comments) -> Option D
  4. Quick Check:

    CLEAN removes non-printable chars = C [OK]
Hint: Use CLEAN to remove hidden characters, TRIM for spaces [OK]
Common Mistakes:
  • Using TRIM instead of CLEAN for hidden characters
  • Trying non-existent functions like REMOVE or STRIP
  • Confusing syntax with other languages
3. Given the text value " Hello World " in a column, what will be the result of TRIM(CLEAN([Column]))?
medium
A. "Hello World"
B. " Hello World "
C. "Hello\u0007 World"
D. "HelloWorld"

Solution

  1. Step 1: Apply CLEAN to remove non-printable characters

    CLEAN removes the hidden character \u0007, so text becomes " Hello World ".
  2. Step 2: Apply TRIM to remove extra spaces

    TRIM removes spaces at start and end, resulting in "Hello World" with a single space between words.
  3. Final Answer:

    "Hello World" -> Option A
  4. Quick Check:

    TRIM + CLEAN cleans spaces and hidden chars = A [OK]
Hint: CLEAN first removes hidden chars, then TRIM removes spaces [OK]
Common Mistakes:
  • Ignoring hidden characters and only trimming spaces
  • Removing spaces inside words incorrectly
  • Confusing escape characters with visible text
4. You wrote the formula TRIM(CLEAN([CustomerName])) but it returns an error. What is the most likely cause?
medium
A. The column name is misspelled or does not exist
B. TRIM cannot be nested inside CLEAN
C. CLEAN only works on numbers, not text
D. TRIM requires a numeric input

Solution

  1. Step 1: Check function nesting rules

    TRIM and CLEAN can be nested; syntax is valid.
  2. Step 2: Verify column name correctness

    If the column name is misspelled or missing, Power BI throws an error.
  3. Final Answer:

    The column name is misspelled or does not exist -> Option A
  4. Quick Check:

    Invalid column name causes error = D [OK]
Hint: Check column names carefully if formula errors occur [OK]
Common Mistakes:
  • Assuming CLEAN or TRIM only work on numbers
  • Thinking nesting functions causes errors
  • Ignoring case sensitivity in column names
5. You have a column Feedback with messy text containing extra spaces and hidden characters. Which DAX formula correctly cleans and trims the text for a new calculated column?
hard
A. CleanTrim = TRIM([Feedback]) + CLEAN([Feedback])
B. CleanTrim = CLEAN(TRIM([Feedback]))
C. CleanTrim = TRIM(CLEAN([Feedback]))
D. CleanTrim = SUBSTITUTE(TRIM([Feedback]), CLEAN([Feedback]), "")

Solution

  1. Step 1: Understand order of operations

    CLEAN should be applied first to remove hidden characters, then TRIM removes extra spaces.
  2. Step 2: Evaluate each option

    CleanTrim = TRIM(CLEAN([Feedback])) applies CLEAN then TRIM correctly. CleanTrim = CLEAN(TRIM([Feedback])) reverses order, which may leave hidden chars. Options C and D misuse functions and produce incorrect results.
  3. Final Answer:

    CleanTrim = TRIM(CLEAN([Feedback])) -> Option C
  4. Quick Check:

    CLEAN then TRIM cleans text best = A [OK]
Hint: Always CLEAN first, then TRIM for best text cleaning [OK]
Common Mistakes:
  • Applying TRIM before CLEAN
  • Adding results instead of nesting functions
  • Using SUBSTITUTE incorrectly to clean text
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard