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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Countrows not working properly with filters

Hi everyone,

 

I'm facing an issue with my DAX formula :

 

CALCULATE(COUNTROWS('ClothesSales'),REMOVEFILTERS('ClothesSales'[Color]))
 
It works fine when I don't apply any date filter on my visuals.
However, when i'm selecting a range period of time and apply the [Color] filter on the page, the function removefilters doesn't work anymore.
 
For example : I would select 1st of January to 31st, my total of clothes sales should by 300.
When applying a filter on the page : [Color] = red, the total should still be 300, since i'm using the removefilters. But it shows an inaccurate amount, like 285, which doesn't event represent the amount of red clothes.
 
When I'm not selecting any range period of time, applying a color filter doesn't seem to bug the formula.
 
I've tried using different DAX ways, but I can't find any that would make this work.
 
This also bugs with other filter functions : CALCULATE(COUNTROWS('ClothesSales'), 'ClothesSales'[Color] = "Red") would bug too.
 
Thank you for your help!
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@Anonymous Easiest fix is to create a separate date table. Then you can grab the min and max of that table without it being impacted by the color filter.



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
Greg_Deckler
Community Champion
Community Champion

@Anonymous Easiest fix is to create a separate date table. Then you can grab the min and max of that table without it being impacted by the color filter.



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler  I think this is the only way. A lot of work for just one measure, but as long as it works, I'm fine with it. Thank you for your help!

Greg_Deckler
Community Champion
Community Champion

@Anonymous Try:

Measure = COUNTROWS(FILTER(ALLEXCEPT(ClothesSales,'ClothesSales'[Color]),[Date]>=MIN('ClothesSales'[Date]) && [Date]<=MAX('ClothesSales'[Date])))


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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler , thank you for your reply.

 

I tried this formula but same result 😪. In the meantime, I've been trying to create a calendar table and use a relationship between my sales dates and the calendar, then use a date slicer based on the calendar table : it works !
However I still don't know how I could create multiple date slicers with this solution (I have multiple date columns in my original table), since you can only create one relationship.

@Anonymous Strange, the formula worked for me. See attached PBIX below sig.



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Strange indeed, even your pbix file doesn't work for me! It should be "8" and it shows "5"...


Elodie_0-1644319239514.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.