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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
davv36
New Member

When adding IF/COALESCE logic to change blanks to zeroes in a measure, the filter context is removed

When adding IF/COALESCE logic to change blanks to zeroes in a measure, the filters are being removed completely on the visuals using those measures!

 

It is effectively changing

 

Measure = SUM(table[column]) 

 

to

 

Measure = COALESCE(SUM(table[column]),0)

 

or the same with an IF instead.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@davv36 , +0 or coalesce can remove context. So in case of date I pushed it back like

 

0 between range
Measure = var _1= SUM(Opportunity[Opportunity count]) +0
var _min = minx(ALLSELECTED('Calendar'), 'Calendar'[Date])
var _max = maxx(ALLSELECTED('Calendar'), 'Calendar'[Date])
return
CALCULATE(if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

@amitchandak , Hi ! Sorry to activate an alreay answered question but I have a similar problem. But instead of a date filter my filter is 'Department'( Salesperson from different department) , how do I change the above mention dax. minx, maxx doesn't work here obviously. Is there a solution? 

amitchandak
Super User
Super User

@davv36 , +0 or coalesce can remove context. So in case of date I pushed it back like

 

0 between range
Measure = var _1= SUM(Opportunity[Opportunity count]) +0
var _min = minx(ALLSELECTED('Calendar'), 'Calendar'[Date])
var _max = maxx(ALLSELECTED('Calendar'), 'Calendar'[Date])
return
CALCULATE(if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Sorry about raising an older question, but I am trying to understand the why with this.

I had a similar issue where the filtering was removed on a Matrix table, with multiple rows, where I did a COALESCE to default to zero.

I applied your fix above and yes, it fixed the problem.

But the question still remains, why?  Why does DAX behave like this?

Hi, I have the same issue. I don't know why remove the context of the filter using COALESCE. I have one table with dates, and more columns, I filter the table by year and with COALESCE(COUNT(),0) I count the number of rows but it appears as 0 rows with dates in 2022

When I have filtered the table by 2023

Thank you - works perfectly!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors