Text.Replace
TextReplaces all occurrences of a substring within a text value.
Syntax
Text.Replace(text as nullable text, old as text, new as text) as nullable textParameters
| Name | Type | Required | Description |
|---|---|---|---|
text | text | Yes | The original text value. |
old | text | Yes | The substring to find and replace. |
new | text | Yes | The replacement text. |
Return Value
text — The text with all occurrences of the old substring replaced by the new substring.
Remarks
Text.Replace finds all occurrences of a substring and replaces them with a new value. The comparison is case-sensitive. To remove a substring entirely, pass an empty string "" as the replacement.
For replacing values at the table level (across entire columns), use Table.ReplaceValue with Replacer.ReplaceText instead.
Examples
Example 1: Clean phone numbers
Table.AddColumn(
Table.SelectColumns(Table.FirstN(Employees, 3), {"Phone"}),
"Cleaned", each Text.Replace([Phone], "-", ""), type text
)Result
Phone | Cleaned | |
|---|---|---|
| 1 | (555) 123-4567 | (555) 1234567 |
| 2 | (555) 234-5678 | (555) 2345678 |
| 3 | (555) 345-6789 | (555) 3456789 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks