OpenBI Docs Buy

REPLACE

A text with a number of its characters, from a position, replaced by another text.

Group: Text. Compatible with DAX.

Syntax

REPLACE ( <old_text>, <start_num>, <num_chars>, <new_text> )
ParameterTypeDescription
old_textTextThe text to change.
start_numWhole numberWhere the replaced part begins: 1 is the text's first character.
num_charsWhole numberHow many characters to take out; 0 only inserts.
new_textTextWhat goes in their place.

Returns

Text. The text with those characters replaced.

Remarks

  • REPLACE works by position. To replace by content, wherever a text occurs, use SUBSTITUTE.
  • With 0 characters the new text is inserted; with empty new text the characters are removed. A start past the end adds the new text at the end.
  • A start below 1, or a negative number of characters, is an error.
  • When old_text and new_text are both blank the result is BLANK; a blank old_text with a new_text gives the new text.

Examples

Replacing, inserting, removing

EVALUATE
ROW (
    "Replace", REPLACE ( "2026-11", 5, 1, "/" ),
    "Insert", REPLACE ( "abc", 2, 0, "X" ),
    "Remove", REPLACE ( "abcdef", 2, 3, "" ),
    "At the end", REPLACE ( "abc", 10, 2, "X" )
)
ReplaceInsertRemoveAt the end
2026/11aXbcaefabcX

A number's digits

The number becomes text first.

EVALUATE
ROW ( "Year", REPLACE ( 2026, 3, 2, "30" ) )
Year
2030

SUBSTITUTE, MID, LEFT, RIGHT.

Last updated · OpenBI Studio 0.3.74