Table.SelectRows
TableReturns a table of rows from the input table that match a selection condition.
Syntax
Table.SelectRows(table as table, condition as function) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The input table to filter. |
condition | function | Yes | A function evaluated for each row. Rows where this returns true are included in the result. |
Return Value
table — A table containing only the rows where the condition function returns true.
Remarks
Table.SelectRows evaluates the condition function for each row in the input table. The condition receives the current row as a record, and you access column values using bracket notation like [ColumnName].
The each keyword is syntactic sugar for (_) =>, making conditions more readable. For example, each [Region] = "East" is equivalent to (_) => _[Region] = "East".
You can combine multiple conditions using and and or operators.
Examples
Example 1: Filter rows by text value
Table.SelectRows(Sales, each [Region] = "East")Result
OrderID | CustomerName | Product | Category | UnitPrice | Quantity | OrderDate | Region | |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | Alice | Widget A | Widgets | 25 | 4 | 1/15/2024 | East |
| 2 | 3 | Charlie | Widget C | Widgets | 15 | 10 | 2/1/2024 | East |
| 3 | 6 | Bob | Thingamajig E | Misc | 120 | 1 | 3/12/2024 | East |
Example 2: Filter rows by numeric comparison
Table.SelectRows(Sales, each [Quantity] > 3)Result
OrderID | CustomerName | Product | Category | UnitPrice | Quantity | OrderDate | Region | |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | Alice | Widget A | Widgets | 25 | 4 | 1/15/2024 | East |
| 2 | 3 | Charlie | Widget C | Widgets | 15 | 10 | 2/1/2024 | East |
| 3 | 5 | Diana | Widget A | Widgets | 25 | 6 | 3/5/2024 | West |
| 4 | 8 | Diana | Widget C | Widgets | 15 | 8 | 4/15/2024 | North |
Example 3: Filter with multiple conditions
Table.SelectRows(Sales, each [Category] = "Gadgets" and [UnitPrice] > 50)Result
OrderID | CustomerName | Product | Category | UnitPrice | Quantity | OrderDate | Region | |
|---|---|---|---|---|---|---|---|---|
| 1 | 4 | Alice | Gadget D | Gadgets | 75 | 1 | 2/10/2024 | North |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks