Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

How to count cases with no data DAX

Dear all,

 

I am having a problem with DAX identifying where there is no data. I can understand why PBI might want to return blanks. But I want 0!

 

I have a matrix of Months by Fruit and I want to count the number of fruit in each month.

 

So I calculate Number of Fruit = COUNTROWS(My Table)

 

Then I create a matrix and I have the columns as months and the rows as fruit. Where there is data I get a count, but where no fruit were sold I just get blanks, where I would prefer 0.

 

I have tried all varities of

IF(ISBLANK(My Table), 0, COUNTROWS(My Table))

COUNTROWS(My Table) + 0

 

Can someone tell me what I am missing?

 

Thank you.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

OK. I have found the solution. You get this issue when your dimensions are in your fact table, if you make sure your dimensions are in Dimension tables and select on the dimenions (show items with no data) then you don't have the same problem.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

OK. I have found the solution. You get this issue when your dimensions are in your fact table, if you make sure your dimensions are in Dimension tables and select on the dimenions (show items with no data) then you don't have the same problem.

Greg_Deckler
Super User
Super User

Something you might try might be to convert the number to text using FORMAT, including a text "0", that might prevent the matrix from eliminating those rows. But, in general, that just sort of how matrices work.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.