COUNTROWS DAX Function (Aggregation)
Counts the number of rows in a table.
Syntax
Parameter | Attributes | Description |
---|---|---|
Table |
The table containing the rows to be counted. |
Return values
Number of rows obtained by the evaluation of the table expression. If the table has no rows, it returns blank.
Remarks
This function can be used to count the rows of a table expression.
Examples
The following are valid syntaxes.
COUNTROWS ( table ) COUNTROWS ( DISTINCT ( table ) ) COUNTROWS ( VALUES ( table ) )
The COUNTROWS function can be used to count the unique values available in a column for the current filter context. However, DISTINCTCOUNT is better in that case. The following expressions are equivalent.
COUNTROWS ( DISTINCT ( table[column] ) ) DISTINCTCOUNT ( table[column] ) )
The COUNTROWS function can be used to check whether a column has only one item filtered/selected in the current filter context. However, HASONEVALUE is better in that case. The following expressions are equivalent.
COUNTROWS ( VALUES ( table[column] ) ) = 1 HASONEVALUE ( table[column] ) )
Related articles
Learn more about COUNTROWS in the following articles:
Related functions
Other related functions are:
Last update: Dec 13, 2019 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo
MSDN documentation: https://docs.microsoft.com/en-us/dax/countrows-function-dax