Replacer.ReplaceText

Replacer

A replacer function that performs substring replacement within text values.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Replacer.ReplaceText as function

Return Value

functionA replacer function that finds and replaces a substring within text cell values.

Remarks

Replacer.ReplaceText is a built-in replacer function used as an argument to Table.ReplaceValue. It performs substring replacement — it finds occurrences of oldValue within the text of each cell and replaces them with newValue, even if the cell contains additional text.

Use Replacer.ReplaceText for partial text replacements (e.g., replacing "Widget" with "Component" inside product names). For replacing entire cell values, use Replacer.ReplaceValue instead.

Examples

Example 1: Substring replacement in product names

Table.SelectColumns(
    Table.ReplaceValue(
        Table.FirstN(Sales, 4),
        "Widget", "Component",
        Replacer.ReplaceText, {"Product"}
    ),
    {"CustomerName", "Product", "Category"}
)
Result
CustomerName
Product
Category
1AliceComponent AWidgets
2BobGadget BGadgets
3CharlieComponent CWidgets
4AliceGadget DGadgets

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks