COUNTX Function (DAX)

How does the COUNTX function (DAX) work?

The COUNTX function (DAX) counts the number of rows that contain a non-blank value or an expression that evaluates to a non-blank value, when evaluating an expression over a table.

COUNTX Formula Syntax


How do you use the COUNTX function?

The COUNTX function is used to count only number values, dates, or strings.

Related Blog Posts

Related Support Forum Posts

Count Zero stock occurrences and time product is out of stock
Average per quarter
Filter out customers who don’t buy certain products

Considerations when using the function

The COUNTX function takes two arguments. The first argument must always be a table, or any expression that returns a table. The second argument is the column or expression that is searched by COUNTX.

If the function finds no rows to count, it returns a blank.

Related Video Tutorials

Formula examples using the COUNTX function


=COUNTX(FILTER(Product,RELATED(ProductSubcategory[EnglishProductSubcategoryName])=”Caps”, Product[ListPrice])

= COUNTX (RELATEDTABLE (East_Sales), IF ([Product] = East_Sales[Product],1,0))

Related DAX Functions

Related Course Modules

Center of Excellence


Download our comprehensive DAX Formula Reference Guide as perfect companion as you learn how to use DAX formulas within Power BI.

Download DAX Formulas Reference Guide
Download DAX Formula Reference Guide