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
fbura
New Member

How to force DAX measure to 0 in the same filter context

I have a measure calculating the sales amount and i'm placing it insiede a line chart with months on the x-axis, a field coming from a table called 'CALENDAR_TREND'. The chart is filtered by a slicer with months, field coming from another table called 'CALENDAR' linked to my previous table 'CALENDAR_TREND'. I want my chart to show values of sales amount, when the measure returns blank, as zeros but doing so mutates the chart filter context showing all the month of a year and placing 0 whenever the measure is blank or the month is outside the range selected with my month slicer.  I just want the chart to show the range of months i selected with those having blank sales amount forced to zero. I already tried using ALLEXCEPT but i was not able to solve my problem.

 

Example:

I want the value of Sales PY to be forced as 0 in the month of August. If i put a new DAX measure usign ALLEXCEPT and add +0 to the calculation of the sales amount, i'll get a chart with months from Jan to Dec even if i filter those values out.

fbura_0-1700563774401.png

 

Any clues will be appreciated, THANK YOU! 🙂

 

 

 

2 REPLIES 2
Anonymous
Not applicable

Hi @fbura ,

 

I think the [Date] column in X axis should come from a continuous Date table. Then if your [Measure]+0 will make your visual expand.

Please try code as below.

Add Range for measure =
VAR _MEASURE = [Measure] + 0
VAR _RANGESTART =
    MINX ( ALL ( 'DataTable' ), 'DataTable'[Date] )
VAR _RANGEEND =
    MAXX ( ALL ( 'DataTable' ), 'DataTable'[Date] )
RETURN
    IF (
        MAX ( 'Date'[Date] ) >= _RANGESTART
            && MAX ( 'Date'[Date] ) <= _RANGEEND,
        _MEASURE
    )

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Rupak_bi
Super User
Super User

I think if else function may solve your purpose. If not, please share sample data.

 



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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