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
| Parameter | Type | Description |
|---|---|---|
text | nullable text | The text to work on; null gives null. |
offset | number | Where the replaced part begins, from 0. |
count | number | How many characters to replace. |
newText | text | What 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"