REPLACE

Updated on

REPLACE is a DAX function that replaces part of a text string with a different text string.

Syntax

REPLACE(
   OldText,
   StartPosition,
   NumberOfCharacters,
   NewText
)
Argument Properties 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

A text string.

Remarks

  • Whereas Microsoft Excel has different functions for use with single-byte and double-byte character languages, DAX uses Unicode and therefore stores all characters as the same length.

  • This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

Example

The following formula creates a new calculated column that replaces the first two characters of the product code in column, [ProductCode], with a new two-letter code, OB.

= REPLACE('New Products'[Product Code],1,2,"OB")

Other functions related to REPLACE are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/dax/replace-function-dax

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy