DAX COUNT Functions: Which One to Choose

COUNT Functions — Power BI | analytics.bi
DAX COUNT functions look simple, but if you choose the wrong one, the results can be wrong. In this article you’ll clearly understand when to use COUNT, COUNTROWS or COUNTX.

If you’re just starting with DAX – I first recommend reading:an introduction to DAX. There you’ll understand the general logic, and here we move on to specific functions.

It’s also important to understand context:row vs filter context, because COUNT functions often depend on filters.

COUNT

COUNTcounts only numeric values.

COUNT(Sales[Amount])

If the column contains text – it’s ignored. That’s why this function is often used too rarely in real projects.

COUNTA

COUNTAcounts all non-empty values.

COUNTA(Sales[Product])

Suitable when you have text, IDs or mixed data.

COUNTROWS

COUNTROWS– one of the most important DAX functions.

COUNTROWS(Sales)

It counts rows regardless of the columns.

In practice you’ll most often use COUNTROWS instead of COUNT.

DISTINCTCOUNT

DISTINCTCOUNTcounts unique values.

DISTINCTCOUNT(Customers[ID])

For example, the number of unique customers is one of the most common business metrics.

COUNTX

COUNTX– an iterating function (more on them here):DAX X functions

COUNTX( Sales, IF(Sales[Amount] > 100, 1) )

Lets you count by a condition – similar to Excel’s COUNTIF.

DAX COUNT funkcijų palyginimas

When to use which?

  • COUNT→ only for numbers
  • COUNTA→ for all data
  • COUNTROWS→ almost always the best choice
  • DISTINCTCOUNT→ for unique records
  • COUNTX→ for conditional counting
If you don’t know what to choose → use COUNTROWS. In 80% of cases it’s the right choice.

What to read next

Conclusion

COUNT functions are simple, but their differences are critically important. The wrong function can give a completely wrong result.

Once you understand these functions together with CALCULATE and controlling the filter context, you’ll be able to build much more accurate and advanced Power BI analyses.

Free cheat sheet

Power Query cheat sheet: automate your report

The key steps, the 5 common mistakes, and when automating is worth it.

  • PDF · 2 pages, practical
  • No spam — value only
Blank Form (#5) (#6)
No spam. Unsubscribe anytime.

Similar Posts