Table.ReplaceMatchingRows
TableReplaces rows that match specified records with new values.
Syntax
Table.ReplaceMatchingRows(table as table, rows as list, optional equationCriteria as any) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The table to update. |
rows | list | Yes | A list of {oldRow, newRow} pairs, where each pair is a two-element list: the record to match and the record to replace it with. |
equationCriteria | any | No | Optional. Column name(s) or comparer to restrict matching to specific fields. |
Return Value
table — The table with matching rows replaced by their corresponding replacement records.
Remarks
Table.ReplaceMatchingRows accepts a list of {oldRecord, newRecord} pairs. For each pair, any table row that matches oldRecord is replaced with newRecord. All matching rows are replaced, not just the first occurrence.
This function operates on whole rows. To replace values within individual cells, use Table.ReplaceValue.
Examples
Example 1: Replace a matching row
Table.ReplaceMatchingRows(
#table({"ID", "Status"}, {{1, "Pending"}, {2, "Done"}, {3, "Pending"}}),
{
{[ID = 1, Status = "Pending"], [ID = 1, Status = "Approved"]}
}
)Result
ID | Status | |
|---|---|---|
| 1 | 1 | Approved |
| 2 | 2 | Done |
| 3 | 3 | Pending |
Example 2: Replace multiple rows
Table.ReplaceMatchingRows(
#table({"Code"}, {{"A"}, {"B"}, {"C"}}),
{
{[Code = "A"], [Code = "Alpha"]},
{[Code = "C"], [Code = "Charlie"]}
}
)Result
Code | |
|---|---|
| 1 | Alpha |
| 2 | B |
| 3 | Charlie |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks