DAX COUNT and COUNTX - Impact of Using Measures V's Calculated Columns

in #excel5 years ago (edited)


DAX for powerpivot course

DAX COUNT and COUNTX – Impact of Using Measures and Columns


In a previous post we looked at DAX SUM and SUMX expressions. We introduced a lot in that article. We mentioned table functions, iterators, row and filter context. We also looked at some measures and calculated columns. Did you notice in that article and video how there can be a different impact using measures and calculated columns?

In this article we are going to slow things down a little. We will look at DAX COUNT and COUNTX – Impact of Using Measures and Columns. Measures and columns work very different. Today, using Count and COUNTX you will see an example of how measures and columns can impact the results in a table or visualization.

COUNT comes from Excel and will count the number of cells in a column that contain a number. COUNT will include all fields that contain a zero. But it will exclude a field if it is blank. Text & true/false are excluded. If you want to count text or logical functions, you need to use COUNTA.

You will not (yet) find COUNTX in Excel. It's a new function to DAX. It works very like SUMX. COUNTX takes two arguments. the first must return a table and the values to count are the second argument. Like COUNT, COUNTX counts numbers so if you want to count text or logical functions you need to use COUNTAX.

Let’s hop into an example and have further look at COUNT and COUNTX. And the impact of creating a calculated column v’s a measure.

Sample Data


We are going to use the same data that we used in the previous article on SUM and SUMX.

Now there is value in Learning with The Excel Club and our Learn and Earn STEEM activities.


We are the first Excel, PowerBI and DAX blog in the world where you can Earn while you Learn.

Find out more now and start earning while you are learning Excel and Power BI

Sort:  

Before, ok. After, great. Calculated columns and measures can give different values due to the difference in aggregation functions which count each row implicitly versus iteration functions which only count the rows as they are called for. Key takeaways continue to be realizing the difference in the way aggregator functions and iterator functions process the data.

Great takeaways

seems like DAX is a little complicated. Do all Excel formulas work in DAX? I need to learn all of the Excel formulas first I think before I can move on to this stuff.

I would recommend that you are rather good at Excel before you move on to powerpivot and DAX. Yes Excel formulas do work in DAX, but it is a little more complex as DAX works on tables and table subsets where as excel works on cells.

Congratulations @theexcelclub! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You distributed more than 11000 upvotes. Your next target is to reach 12000 upvotes.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Vote for @Steemitboard as a witness to get one more award and increased upvotes!


Congratulations @theexcelclub!
You raised your level and are now a Dolphin!

Vote for @Steemitboard as a witness to get one more award and increased upvotes!