COUNTROWS
The number of rows of a table.
Group: Aggregation. Compatible with DAX.
Syntax
COUNTROWS ( [<table>] )
| Parameter | Type | Description |
|---|---|---|
table | Table optional | The table whose rows are counted: a table of the model or a table expression. |
Returns
Whole number. The number of rows of the table in the current filter context.
Remarks
- Rows are counted whatever their cells hold, blanks included.
- An empty table gives BLANK, not 0.
COUNTROWS ( FILTER ( ... ) )andCOUNTROWS ( VALUES ( column ) )are the usual ways to count the rows that meet a condition, or a column's different values.- Always give the table: a call without one is an error in OpenBI.
Examples
Rows of two tables
EVALUATE
ROW (
"Sales rows", COUNTROWS ( Sales ),
"Products", COUNTROWS ( Products )
)
| Sales rows | Products |
|---|---|
| 2160 | 4 |
Rows that meet a condition
Sales rows of more than 1,000 liters, by product.
EVALUATE
SUMMARIZECOLUMNS (
Sales[Product],
"Big months", COUNTROWS ( FILTER ( Sales, Sales[Liters] > 1000 ) )
)
ORDER BY Sales[Product]
| Sales[Product] | Big months |
|---|---|
| Cider | 121 |
| IPA | 125 |
| Lettøl | 16 |
| Pils | 252 |
An empty table
EVALUATE
ROW ( "Rows", COUNTROWS ( FILTER ( DATATABLE ( "n", INTEGER, { { 1 } } ), [n] > 5 ) ) )
| Rows |
|---|
| (blank) |