By: Ben Richardson Last updated: May 23rd, 2022
News & tips
The Replace function in DAX is a Power BI text function that you use to replace part of a text string with a different text string.
It is relatively straightforward to use and appropriate for DAX beginners to be using.
|Old text:||A reference to a text column or a string of text containing the characters you want to replace.|
|Start number:||The position of the first character in the old text that you want to replace with new text.|
|Number of characters:||The total number of characters you want to change|
|New text:||The replacement text for the characters in the old text that were specified.|
The return value of the replace function in DAX is a text string.
Lets start with a very simple example of using the replace function.
We would like to replace the string “DEF” with “EEE.”
First, choose New Column.
Next, as shown below, type the Replace formula in the formula bar.
This will give you the result below.
A more realistic example might be that we want to change an old text string (SO) for a new text string (Sales Order) in the calculated column calculations below.
The outcome of the replace function in DAX is shown below.
Remember that replace allows you to replace a portion of a text string with another text string starting at a certain spot.