Forum Discussion
COUNTBLANK and Count Zeroes?
Hello,
I have a several columns that have text values and I want a DAX that could count how many Blanks there are AND how many zeroes there are. I already use the COUNTBLANK DAX but I would like one that also incorporates zeroes.
Thanks you!
How about something like this?
COUNTROWS ( FILTER ( Table1, ISBLANK ( Table1[ColA] ) || Table1[ColA] = "0" ) )Or a completely different approach:
CALCUALTE ( COUNT ( Table1[ColA] ), ISBLANK ( Table1[ColA] ) ) + CALCUALTE ( COUNT ( Table1[ColA] ), Table1[ColA] = "0" )
8 Replies
- AlexisOlson
Super User
How about something like this?
COUNTROWS ( FILTER ( Table1, ISBLANK ( Table1[ColA] ) || Table1[ColA] = "0" ) )Or a completely different approach:
CALCUALTE ( COUNT ( Table1[ColA] ), ISBLANK ( Table1[ColA] ) ) + CALCUALTE ( COUNT ( Table1[ColA] ), Table1[ColA] = "0" ) - Tahreem24
Super User
If you want to count zero text in your column so use the below syntax:
Count Zero = Calculate( count(Table [ColumnName]), Filter(Table, Table[ColumnName]="0"))
- parry2k
Super User
Anonymous you can get a count of zeros by following
Count Zero = CALCULATE ( COUNTROWS ( Table ), Table[COlumn] = "0" ) - parry2k
Super User
Anonymous I will go with AlexisOlson solution if you want one measure to count for both blank and zero values but if you want separate then add a separate measure as suggested earlier.
Tahreem24 should avoid using the FILTER function, it is an iterator and can have a performance impact on large tables. Just 2 cents on your solution.
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- Tahreem24
Super User
parry2k - I hope you got my point by refering the below user's post. That's why recommend them to use Filter to get the correct result.
https://community.powerbi.com/t5/Desktop/Filter-not-working-on-measure-field/m-p/1442932
By the way, thanks for the caution. 🙂
- AnonymousNot applicable
Thank you for all your replies, I like this formula best:
COUNTROWS ( FILTER ( Table1, ISBLANK ( Table1[ColA] ) || Table1[ColA] = "0" ) )