Table.SelectRows

Table

Returns a table of rows from the input table that match a selection condition.

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

Syntax

Table.SelectRows(table as table, condition as function) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe input table to filter.
conditionfunctionYesA function evaluated for each row. Rows where this returns true are included in the result.

Return Value

tableA 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
11AliceWidget AWidgets2541/15/2024East
23CharlieWidget CWidgets15102/1/2024East
36BobThingamajig EMisc12013/12/2024East

Example 2: Filter rows by numeric comparison

Table.SelectRows(Sales, each [Quantity] > 3)
Result
OrderID
CustomerName
Product
Category
UnitPrice
Quantity
OrderDate
Region
11AliceWidget AWidgets2541/15/2024East
23CharlieWidget CWidgets15102/1/2024East
35DianaWidget AWidgets2563/5/2024West
48DianaWidget CWidgets1584/15/2024North

Example 3: Filter with multiple conditions

Table.SelectRows(Sales, each [Category] = "Gadgets" and [UnitPrice] > 50)
Result
OrderID
CustomerName
Product
Category
UnitPrice
Quantity
OrderDate
Region
14AliceGadget DGadgets7512/10/2024North

Compatibility

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