Table.SelectMatchingRows
Keeps only the rows equal to one of the rows you list.
Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Table.SelectMatchingRows(table as table, rows as list, optional equationCriteria as any) as table
| Parameter | Type | Description |
|---|---|---|
table | table | The table to take rows from. |
rows | list | The rows to keep, each as a record. |
equationCriteria | any optional | The columns that decide a match, as a name or a list of names. |
Returns
table. The matching rows, in the table's order.
Remarks
- It is the opposite of
Table.RemoveMatchingRows: the rows that one takes out, this one keeps.
Compared with Power Query
Microsoft's Power Query M reference doesn't list Table.SelectMatchingRows. For a query that must also run in Power BI Desktop, write the filter with Table.SelectRows, such as Table.SelectRows(Stock, each List.Contains({"Oslo"}, [Shop])).
Examples
The rows of one shop
Table.SelectMatchingRows(#table({"Shop", "Product"}, {{"Oslo", "Chair"}, {"Bergen", "Desk"}, {"Oslo", "Desk"}}), {[Shop = "Oslo"]}, "Shop")
| Shop | Product |
|---|---|
| Oslo | Chair |
| Oslo | Desk |
Two whole rows
Table.SelectMatchingRows(#table({"Shop", "Product"}, {{"Oslo", "Chair"}, {"Bergen", "Desk"}, {"Oslo", "Desk"}}), {[Shop = "Oslo", Product = "Chair"], [Shop = "Bergen", Product = "Desk"]})
| Shop | Product |
|---|---|
| Oslo | Chair |
| Bergen | Desk |