OpenBI Docs Buy

Table.ReplaceMatchingRows

Swaps every row that equals a given row for another row.

Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Table.ReplaceMatchingRows(table as table, replacements as list, optional equationCriteria as any) as table
ParameterTypeDescription
tabletableThe table to change.
replacementslistPairs {old row, new row}, each row a record.
equationCriteriaany
optional
The columns that decide a match, as a name or a list of names.

Returns

table. The same number of rows, the matching ones replaced.

Remarks

  • Every row that matches is replaced, not only the first.
  • Give the new row with all of the table's columns.

Examples

A new price for the chairs

Table.ReplaceMatchingRows(
    #table({"Product", "Price"}, {{"Chair", 50}, {"Desk", 120}, {"Chair", 50}}),
    {{[Product = "Chair", Price = 50], [Product = "Chair", Price = 55]}})
ProductPrice
Chair55
Desk120
Chair55

Matching on one column

Table.ReplaceMatchingRows(
    #table({"Product", "Price"}, {{"Chair", 50}, {"Desk", 120}}),
    {{[Product = "Desk"], [Product = "Desk", Price = 99]}},
    "Product")
ProductPrice
Chair50
Desk99

Table.ReplaceValue, Table.RemoveMatchingRows, Table.ReplaceRows.

Last updated · OpenBI Studio 0.3.79