OpenBI Docs Buy

Text.ReplaceRange

A text with the characters at a position replaced by another text, which may be longer or shorter.

Group: Text and characters. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Text.ReplaceRange(text as nullable text, offset as number, count as number, newText as text) as nullable text
ParameterTypeDescription
textnullable textThe text to work on; null gives null.
offsetnumberWhere the replaced part begins, from 0.
countnumberHow many characters to replace.
newTexttextWhat to put in their place.

Returns

nullable text. The new text; an error when the part reaches past the end.

Examples

A new postcode

Text.ReplaceRange("NO-0150", 3, 4, "0250")
"NO-0250"

A longer text in a short slot

Text.ReplaceRange("SKU-1", 4, 1, "1001")
"SKU-1001"

Text.Replace, Text.Insert, Text.RemoveRange.

Last updated · OpenBI Studio 0.3.79