DAX function
SUBSTITUTE — DAX function reference
Replace text by match.
Syntax
dax
SUBSTITUTE(<text>, <old_text>, <new_text>, [<instance_num>])
Examples
dax
SUBSTITUTE([Code], "-", "")
→ Text
dax
SUBSTITUTE(SUBSTITUTE(Product[SKU], "-", ""), " ", "")
→ Strips both dashes and spaces from a SKU for matching another system's format
dax
SUBSTITUTE(Customer[Phone], "+1", "", 1)
→ Removes only the first occurrence of a country-code prefix, via the optional instance_num argument
Common mistakes & gotchas
- SUBSTITUTE is case-sensitive — SUBSTITUTE([Code], "abc", "") will not touch "ABC"; use UPPER/LOWER first if the match needs to be case-insensitive.
- Without instance_num it replaces every occurrence of old_text; forgetting that can over-replace when the pattern appears more than once in the string.
Related DAX functions
From Text