DAX function
COUNTROWS — DAX function reference
Count rows in a table.
Syntax
dax
COUNTROWS(<table>)
Examples
dax
COUNTROWS(Sales)
→ A number
dax
COUNTROWS(FILTER(Sales, Sales[Amount] > 1000))
→ Count of large orders
A common alternative to DISTINCTCOUNT when you need the underlying table for other calculations too.
dax
COUNTROWS(VALUES(Sales[CustomerID]))
→ Distinct customer count
Common mistakes & gotchas
- Prefer COUNTROWS over COUNT when you just want the row count.
- COUNTROWS(Table) counts every row visible in the current filter context, including rows with blank values — different from COUNT/COUNTA which inspect one specific column.
- COUNTROWS(VALUES(column)) and DISTINCTCOUNT(column) usually match, but VALUES(column) includes a blank row when the column has unmatched or blank values, while DISTINCTCOUNT excludes it — the counts can differ by one.
Related DAX functions
From Aggregations