COUNTROWS Function (DAX)

How does the COUNTROWS function (DAX) work?

The COUNTROWS function (DAX) counts the number of rows in the specified table, or in a table defined by an expression.

COUNTROWS Formula Syntax

COUNTROWS(
     <table>
)

How do you use the COUNTROWS function?

This function can be used to count the number of rows in a base table, but more often is used to count the number of rows that result from filtering a table, or applying context to a table.

Related Blog Posts

Related Support Forum Posts

If Is Blank in Countrows card visual
Using COUNTROWS but also managing many filters – DAX formula optimization
Using virtual tables with COUNTROWS

Considerations when using the COUNTROWS function

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. Microsoft Excel also returns a zero if no rows are found that meet the conditions.

Related Video Tutorials

Formula examples using the COUNTROWS function

=COUNTROWS(‘Orders’)

=COUNTROWS(RELATEDTABLE(ResellerSales))

= COUNTBLANK (SalesTarget[SalesTarget])

Related DAX Functions

Related Course Modules

Ultimate-Beginners-Guide-To-PowerBI

DOWNLOAD

To access our comprehensive DAX formula reference guide just insert your email address below. The resource will download immediately and we’ll also email it to you.