Home » DAX » DAX – COUNTROWS Function

DAX – COUNTROWS Function

Countrows DAX

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 Aggregation 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 to count the total number of rows in the “Orders” table/dataset.

COUNTROWS =
COUNTROWS(Orders)

Here, Orders is Dataset name

Step-2: Now, add a card visual to visualize the output of the measure.

CoutRows DAX

CoutRows DAX

Step-3: If you want to see Region wise counts, To achieve this, place a slicer on the report canvas and then drag the “Region” column onto it.

Countrows DAX Output

Countrows DAX Output




Step-4: You can also use COUTROWS DAX function with FILTER DAX, if you wish to count the rows associated with a specific Region-

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