Table.RowCount

Table

Returns the number of rows in a table.

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

Syntax

Table.RowCount(table as table) as number

Parameters

NameTypeRequiredDescription
tabletableYesThe table to count rows in.

Return Value

numberThe number of rows in the table.

Remarks

Table.RowCount returns the total number of rows in a table as a single number. This is commonly used inside Table.Group aggregations to count the rows in each group, or in conditional logic to check the size of a table.

Note that this function returns a scalar value (a number), not a table. To display the result as a table in an example, it is wrapped in a record-to-table conversion.

Examples

Example 1: Count rows in a table

let
    Count = Table.RowCount(Sales)
in
    #table({"RowCount"}, {{Count}})
Result
RowCount
18

Example 2: Count rows per group

Table.Group(Sales, "Region", {{"Orders", each Table.RowCount(_), Int64.Type}})
Result
Region
Orders
1East3
2West3
3North2

Compatibility

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