March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hey everyone,
How can I count all the distinct values in a column except the blank(null) values? I tried several things but nothing works.
Solved! Go to Solution.
=calculate( distinctcount(MyTable[MyColumn]), MyTable[MyColumn] <> BLANK())
any ways that doesn't require dax measure? purpose is, measure is not considered in drill through function
Great work and thank you! Seems like not counting the blanks would be implied. Yet another reason I'm having a hard time converting from MD to tabular
Doesn't look like this has been updated in a while. While the solution does in fact work, you now have the option of DISTINCTCOUNTNOBLANK
ie.
=calculate( distinctcount(MyTable[MyColumn]), MyTable[MyColumn] <> BLANK())
Excellent @Anonymous. Thanks a lot!
Good solution...
One issue.. It if you have duplicate values it counts it as one. For example, if my table column is what people chose as a favorite animal, it would have a lot of people choosing dogs. There would be for example 50 dogs, but this formula would count the 50 instances of "Dog" as one. (Just a simple example). If there's 50, you want the count to reflect that.
MeasureHappy = calculate(count(MyTable[MyColumn]), MyTable[MyColumn] <> BLANK())
Changing from distinctcount, to just plainly count will resolve this, for anyone not looking to count dups as a singular. (If you want a zero instead of null
MeasureHappy = calculate(count(MyTable[MyColumn]), MyTable[MyColumn] <> BLANK()) + 0
Happy Intellegence
David
Hey @Anonymous
If the distinctcount of a column is equal to zero then distinctcount returns BLANK(null). Can I fix this to show 0 instead of null?
Hi @Anonymous,
you can use this:
=
CALCULATE ( DISTINCTCOUNT ( MyTable[MyColumn] ), MyTable[MyColumn] <> BLANK () ) + 0
<Blank> + 0 equals 0
Kind regards
Oxenskiold
Thanks a lot!!! 🙂
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
86 | |
77 | |
57 | |
52 |
User | Count |
---|---|
201 | |
137 | |
108 | |
73 | |
68 |