REPLACE DAX Function in Power BI

The REPLACE function in DAX (Data Analysis Expressions) for Power BI is used to substitute a portion of a text string with a different text string, based on the position of the characters.

DAX Syntax REPLACE(text, start_num, num_chars, replacement_text)

The function has the following parameters:

Example: Let’s create a new calculated column in the Power BI.

DAX

REPLACE Column = REPLACE('Table'[Name], 1, 2, "ZZ")

The output of the above dax code is shown below:

REPLACE dax function in Power BI

The following are the key points of the REPLACE dax function:
• 1-based indexing: DAX uses 1-based indexing, meaning the first character is at position 1, not 0.
• The REPLACE function always returns a text string.
• Fixed position replacement: REPLACE is useful when you know the exact position and length of the text you want to change. If we need to replace text based on its content rather than position, you might want to consider using the SUBSTITUTE function.

Difference between REPLACE and SUBSTITUTE: