0
0
Power BIbi_tool~20 mins

Trim and clean text in Power BI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Text Cleaning Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
dax_lod_result
intermediate
2:00remaining
Removing Extra Spaces with TRIM
Given a column 'CustomerName' with values like ' John Doe ', which DAX expression correctly removes all leading and trailing spaces but keeps single spaces between words?
ATRIM(CLEAN('Table'[CustomerName]))
BCLEAN('Table'[CustomerName])
CSUBSTITUTE('Table'[CustomerName], " ", "")
DTRIM('Table'[CustomerName])
Attempts:
2 left
💡 Hint

Think about which function removes spaces only at the start and end, not inside the text.

visualization
intermediate
2:00remaining
Visualizing Cleaned Text Length
You want to create a Power BI card visual that shows the average length of cleaned product descriptions. Which measure correctly calculates the average length after trimming and cleaning the 'ProductDescription' column?
AAverageLength = AVERAGEX('Products', LEN('Products'[ProductDescription]))
BAverageLength = AVERAGEX('Products', LEN(TRIM(CLEAN('Products'[ProductDescription]))))
CAverageLength = AVERAGE(LEN(TRIM('Products'[ProductDescription])))
DAverageLength = AVERAGEX('Products', LEN(CLEAN('Products'[ProductDescription])))
Attempts:
2 left
💡 Hint

Remember to apply both TRIM and CLEAN before measuring length, and use AVERAGEX to iterate rows.

data_modeling
advanced
2:00remaining
Handling Non-Printable Characters in Data Model
You notice your customer feedback text contains hidden non-printable characters causing filtering issues. What is the best approach to clean this text in your Power BI data model?
ACreate a calculated column using CLEAN and TRIM functions on the feedback text.
BApply only TRIM function to remove spaces from the feedback text.
CUse SUBSTITUTE to replace spaces with empty strings in the feedback text.
DIgnore cleaning and handle issues in report filters.
Attempts:
2 left
💡 Hint

Think about removing both non-printable characters and extra spaces.

🔧 Formula Fix
advanced
2:00remaining
Debugging Unexpected Spaces in Text Output
A measure uses this DAX: CleanName = TRIM(CLEAN('Customers'[Name])) but the report still shows extra spaces inside names like 'John Doe'. What is the cause?
Power BI
CleanName = TRIM(CLEAN('Customers'[Name]))
AThe column 'Name' contains tabs that CLEAN cannot remove.
BCLEAN does not remove spaces, so extra spaces remain inside the text.
CTRIM only removes leading and trailing spaces, not multiple spaces inside the text.
DThe measure syntax is incorrect and causes errors.
Attempts:
2 left
💡 Hint

Consider what TRIM does and does not do.

🧠 Conceptual
expert
3:00remaining
Best Practice for Cleaning Text in Large Datasets
In a large Power BI dataset, which approach is best to efficiently clean text columns by removing non-printable characters and trimming spaces without slowing report performance?
APerform text cleaning in the data source or Power Query before loading data into the model.
BUse calculated columns with CLEAN and TRIM in the data model for all text columns.
CApply CLEAN and TRIM in every measure that uses text columns dynamically.
DIgnore cleaning and rely on report users to handle text inconsistencies.
Attempts:
2 left
💡 Hint

Think about where cleaning is most efficient: before or after loading data.