REPLACE DAX Function (Text)
Replaces part of a text string with a different text string.
Syntax
| Parameter | Attributes | Description |
|---|---|---|
| OldText |
The string of text that contains the characters you want to replace. |
|
| StartPosition |
The position of the character in old_text that you want to replace with new_text. |
|
| NumberOfCharacters |
The number of characters that you want to replace. |
|
| NewText |
The replacement text. |
Return values
The resulting string after applying the replacements.
Remarks
The StartPosition starts from 1 for the first character in the string.
Examples
-- REPLACE lets you replace part of a string with a new string
DEFINE
VAR Val = "DAX is so cool !"
VAR Replacement = "fantastic"
EVALUATE
{
( "Original", Val ),
( "Replaced", REPLACE ( Val, 11, 4, Replacement ) )
}
| Value1 | Value2 |
|---|---|
| Original | DAX is so cool ! |
| Replaced | DAX is so fantastic ! |
Related functions
Other related functions are:
Last update: Oct 22, 2025 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo
Microsoft documentation: https://docs.microsoft.com/en-us/dax/replace-function-dax
