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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
MKPartner
Helper I
Helper I

Display 0 value on graph in specific range of dates

Hello All, 

 

I know that similar issue was raised couple times but I didn't find solution to my case or I'm not able to tweak my code. 

 

I'd like to display 0 value on graph when no data are available. I'm calculating PPM measure from Rejected part divided for All parts. When Rejected parts = 0 then nothing appear on graph. I'm trying to use below DAX code to fix it but results isn't sufficient for me: 

 

PPM12M_v2 = 
VAR MaxDate =
    MAX ( 'DATE_DUP'[WC_Month] )
VAR MinDate =
    DATE ( YEAR ( MaxDate ), MONTH ( MaxDate ) - 12, DAY ( MaxDate ) )
VAR PPM =
    IF(
        ISBLANK((SUMX('PPM returns','PPM returns'[Meters accepted by FE])/SUMX('PPM Despatches','PPM Despatches'[qty]))*1000000),
        0,
        (SUMX('PPM returns','PPM returns'[Meters accepted by FE])/SUMX('PPM Despatches','PPM Despatches'[qty]))*1000000
    )
       
RETURN
    CALCULATE (
        PPM,
        FILTER ( 'COQ Calendar', 'COQ Calendar'[WC_Month] > MinDate && 'COQ Calendar'[WC_Month] <= MaxDate )
    )

 

Result of above code is below: 

 

Error.JPG

 

Can you help me to fix it ? 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MKPartner , if that is blnak and you want make it 0, Try 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

2 REPLIES 2
amitchandak
Super User
Super User

@MKPartner , if that is blnak and you want make it 0, Try 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

Thank you for your support. I have tweaked your DAX as below & it works. I didn;t realized to do it by this way. 

 

PPM12M_v2 = 
var _1= ((SUMX('PPM returns','PPM returns'[Meters accepted by FE])/SUMX('PPM Despatches','PPM Despatches'[qty]))*1000000)+0
var _max = MAX ( 'DATE_DUP'[WC_Month] )
var _min =  DATE ( YEAR ( _max ), MONTH ( _max ) - 12, DAY ( _max ) )

return
CALCULATE(if(max('COQ Calendar'[WC_Month]) <_min || max('COQ Calendar'[WC_Month]) >_max , BLANK(), _1),
        FILTER ( 'COQ Calendar', 'COQ Calendar'[WC_Month] > _min && 'COQ Calendar'[WC_Month] <= _max )
)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.