OpenBI Docs Buy

COUNTROWS

The number of rows of a table.

Group: Aggregation. Compatible with DAX.

Syntax

COUNTROWS ( [<table>] )
ParameterTypeDescription
tableTable
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 ( ... ) ) and COUNTROWS ( 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 rowsProducts
21604

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
Cider121
IPA125
Lettøl16
Pils252

An empty table

EVALUATE
ROW ( "Rows", COUNTROWS ( FILTER ( DATATABLE ( "n", INTEGER, { { 1 } } ), [n] > 5 ) ) )
Rows
(blank)

COUNT, DISTINCTCOUNT, FILTER, VALUES, ISEMPTY.

Last updated · OpenBI Studio 0.3.74