COUNTROWS is a DAX function that counts the number of rows in a table.
Syntax
COUNTROWS( Table )
Argument | Properties | Description |
---|---|---|
Table | Optional | The table containing the rows to be counted. |
COUNTROWS is a DAX function that counts the number of rows in a table.
COUNTROWS( Table )
Argument | Properties | Description |
---|---|---|
Table | Optional | The table containing the rows to be counted. |
A whole number.
This function can be used to count the number of rows in a base table, but more often is used to count the number of rows that result from filtering a table, or applying context to a table.
When the table argument contains no rows, the function returns BLANK.
To learn more about best practices when using COUNT and COUNTROWS, see Use COUNTROWS instead of COUNT in DAX.
This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.
The following example shows how to count the number of rows in the table Orders. The expected result is 52761.
= COUNTROWS('Orders')
The following example demonstrates how to use COUNTROWS with a row context. In this scenario, there are two sets of data that are related by order number. The table Reseller contains one row for each reseller; the table ResellerSales contains multiple rows for each order, each row containing one order for a particular reseller. The tables are connected by a relationship on the column, ResellerKey.
The formula gets the value of ResellerKey and then counts the number of rows in the related table that have the same reseller ID. The result is output in the column, CalculatedColumn1.
= COUNTROWS(RELATEDTABLE(ResellerSales))
The following table shows a portion of the expected results:
ResellerKey | CalculatedColumn1 |
---|---|
1 | 73 |
2 | 70 |
3 | 394 |
Other functions related to COUNTROWS are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy