Replacer.ReplaceText
Replaces every occurrence of a piece of text inside a text: the replacer for parts of values.
Group: Splitters, combiners, replacers and comparers. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Replacer.ReplaceText(text as nullable text, old as text, new as text) as nullable text
| Parameter | Type | Description |
|---|---|---|
text | nullable text | The text to change; null gives null. |
old | text | The text to look for, matched with its capitals. |
new | text | What to put in its place. |
Returns
nullable text. The text with every occurrence replaced.
Remarks
Table.ReplaceValueandList.ReplaceValuetake it to replace inside cells: "City" in "Oslo City" is replaced.Replacer.ReplaceValuereplaces whole values only.
Examples
Inside the cells of a column
let
Shops = #table({"Shop"}, {{"Oslo City"}, {"Bergen City"}})
in
Table.ReplaceValue(Shops, "City", "Centre", Replacer.ReplaceText, {"Shop"})
| Shop |
|---|
| Oslo Centre |
| Bergen Centre |
Every occurrence
Replacer.ReplaceText("Sales Sales", "Sales", "Revenue")
"Revenue Revenue"
Related functions
Replacer.ReplaceValue, Table.ReplaceValue, List.ReplaceValue, Text.Replace.