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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.