Shorten long names with LEFT, LEN and UPPER
Trim long product names for narrow visuals: measure the text with LEN, cut it with LEFT and add “...” only where it was cut.
You will learn to
- Count characters with LEN
- Keep the start of a text with LEFT
- Combine text functions with IF and a variable
How it works
DAX has the same text tools you know from Excel:
- `LEN(text)` counts the characters, spaces included. - `LEFT(text, n)` keeps the first n characters; `RIGHT(text, n)` keeps the last n. - `UPPER(text)` and `LOWER(text)` change the case.
To use them in a measure, get the row’s text with `SELECTEDVALUE(column)`. When the same piece appears several times in a formula, store it once with `VAR Name = …` and use the name after `RETURN`.
A common job is shortening long labels so a chart axis stays readable. Cut only the names that are too long, and add “...” so readers know something was cut.
Practice it hands-on with a real data model and a live report that updates as you type.
Category Code = UPPER(LEFT(SELECTEDVALUE(Product[Category]), 3))