TRIM(), UPPER() & LOWER()
Learn how DAX's TRIM, UPPER, and LOWER clean up text, and why TRIM does more than Power Query's Text.Trim -- it also collapses internal runs of spaces down to one, not just the leading and trailing ones.
TRIM(), UPPER() & LOWER()
These are the DAX equivalents of Power Query's Text.Trim(), Text.Upper() & Text.Lower() — with one real difference in what TRIM() actually removes.
TRIM(text)
UPPER(text)
LOWER(text)UPPER() and LOWER()
UPPER("active")
LOWER("ACTIVE")UPPER("active") -> "ACTIVE"
LOWER("ACTIVE") -> "active"These behave exactly as expected, and exactly like their Power Query counterparts. The subtlety is comparison, covered below: DAX and Power Query treat case differently.
TRIM() Also Collapses Internal Spaces
TRIM(" Widget Sales ")" Widget Sales " -> "Widget Sales"DAX's TRIM() mirrors Excel's TRIM(): it removes leading and trailing spaces, and collapses every internal run of multiple spaces down to a single space. This is different from Power Query's Text.Trim(), which only touches the leading and trailing ends — internal spaces, however many there are, pass through completely unchanged.
Try it live — dots mark spaces
12 characters — internal spaces collapsed
14 characters — internal spaces untouched
— same input, 2 more characters survive Text.Trim() than TRIM(), all of them internal spaces.
The same messy source text produces two different-length results depending on which layer cleans it: TRIM() in DAX quietly fixes a double space typed between two words; Text.Trim() in Power Query leaves it exactly as it was.
" Widget Sales "
TRIM(...) -> "Widget Sales" (11 chars, one space between words)
Text.Trim(...) -> "Widget Sales" (14 chars, all 3 internal spaces survive)UPPER() / LOWER() for Comparison, Not Just Display
DAX text comparisons are case-insensitive: "Active" = "ACTIVE" is TRUE, so LOWER() isn't needed to compare in DAX. Power Query is the opposite: its comparisons are case-sensitive, and that's where normalizing case before a merge or a filter matters. When you do need a case-sensitive check in DAX, use EXACT():
Exact Code Match = EXACT([Code], "ABC-01")UPPER() and LOWER() in DAX are mainly for display, such as a consistent label in a title.
Common Mistakes
Assuming TRIM() Only Touches the Ends, Like Text.Trim()
Porting a value cleaned with Text.Trim() in Power Query into a DAX calculated column and re-cleaning it with TRIM() can produce a shorter result than expected — any internal double space that survived Text.Trim() gets collapsed by TRIM(), which may or may not be desired depending on whether that internal spacing was meaningful.
Expecting Text.Trim() to Catch an Internal Double Space
The reverse mistake: assuming Power Query already normalized internal spacing because a value "went through Text.Trim()" — it didn't touch anything except the two ends.
Converting Case to Compare in DAX
Adding LOWER() to both sides of a DAX comparison changes nothing, because DAX already ignores case. If two values that differ only in case need to be treated as different, use EXACT(). And remember the model stores "North" and "north" as one value anyway.
Best Practices
- Use
TRIM()when internal double-spacing genuinely needs cleaning up, not just leading/trailing whitespace. - Don't assume a value is already fully cleaned just because it passed through the other language's trim function — the two aren't equivalent.
- Don't convert case to compare in DAX; it already ignores case. Normalize case in Power Query, where comparisons and merges are case-sensitive.
Next Steps
Need the rest of DAX's text functions in one place — CONCATENATEX, SUBSTITUTE, FORMAT, EXACT? See the DAX Text Functions Cheat Sheet.
BLANK() vs 0: ISBLANK() and the Comparison Trap
Learn why DAX measures return BLANK() instead of 0 for missing data, why BLANK() = 0 evaluates to TRUE, and why ISBLANK() is the only reliable way to test for an actual blank.
DATEDIFF()
Learn why DAX's DATEDIFF counts calendar boundaries crossed between two dates, not full elapsed periods -- so a 1-day gap across a month-end can return 1 for MONTH, and how that differs from a simple day-count division.