Home » DAX » DAX – COUNTROWS Function

DAX – COUNTROWS Function

COUNTROWS DAX Function

The COUNTROWS function is used to counts the number of rows in the specified table, or in a table defined by an expression. This function comes under Statistical Functions DAX category.




Refer similar DAX : DISTINCTCOUNTCOUNTBLANK COUNT, COUNTA & COUNTX

Syntax:

COUNTROWS(<table>)

Description:

S no. Parameter Description
1 table The name of the table that contains the rows to be counted, or an expression that returns a table.

Let’s understand with an example:

Download sample Dataset – SuperStoreUS-2015.xlxs and import into Power BI desktop.




Step-1: Create a measure for counts total no of rows in Orders Table/ Dataset.

COUNTROWS =
COUNTROWS(Orders)

Here Orders is Dataset name

Step-2: Now take one card visual to see the output of measure

CoutRows DAX

CoutRows DAX

Step-3: If you want to see Region wise counts, so for this take on slicer and Drag region column over it.

Countrows DAX Output

Countrows DAX Output



Step-4: You can also use COUTROWS DAX function with FILTER DAX, suppose you want to count particular Region rows

COUNTROWS = CALCULATE(
COUNTROWS(Orders),
FILTER(Orders, Orders[Region]="East"))

It will return number of rows under East region.

Note:

Whenever there are no rows to aggregate, the function returns a blank. However, if there are rows, but none of them meet the specified criteria, the function returns 0.

Refer similar DAX : DISTINCTCOUNTCOUNTBLANK COUNT, COUNTA & COUNTX




Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.

Leave a Reply