Replace Function

  1. Home
  2. Replace Function

REPLACE function is used to replace part of a text string, depending on the number of characters you specify, with a different text string.

Syntax

REPLACE(<old_text>, <start_num>, <num_chars>, <new_text>)  

Defined Parameters

TermDefinition
old_textIt represents the string of text containing the characters you want to replace, or a reference to a column that contains text.
start_numIt represents the position of the character in old_text that you want to replace with new_text.
num_charsIt represents the number of characters that you want to replace. 

Warning: If the argument, num_chars, is blank or references a column that evaluates to a blank, the string for new_text is inserted at the position, start_num, without replacing any characters. It has the same behavior as in Excel.
new_textIt represents the replacement text for the specified characters in old_text.

Return value

It represents a text string.

Note –

  • DAX uses Unicode and therefore stores all characters as the same length, on the other hand, Microsoft Excel has different functions for use with single-byte and double-byte character languages,
  • Secondly, replace function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

For More Visit: REPLACE Function

SUBSTITUTE Function

It is used to replaces existing text with new text in a text string.

SUBSTITUTE(<text>, <old_text>, <new_text>, <instance_num>)

Microsoft Exam DA-100 Free Practice Test
Menu