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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
loafers
Frequent Visitor

Measure to show blank if in future period but add 0 to all prior periods if there is no data?

I have a matrix and line graph below with the same measures.

In the matrix, I have months from date table going across and going down are the measures for each year. 

 

In the line graph, I want to have it connected for all months and if there is no data then to connect on the zero. The measure calc is just time intelligence: 

CALCULATE([Revenue],DATESMTD(DATEADD('Date'[Date],0,MONTH)))
 
With the current measure, the line graph will become disconnected if there is a zero as seen below. I can add a +0 to the end of the measure and it will connect for each month. However, the issue with the +0 at the end is that it will show zero for future periods even though they haven't happened yet and I want it to remain blank if there is no data for those periods yet. 
 
This is only an issue for the current year measure since for prior years I'm fine with the +0 at the end. Is there a better way to write the measure so that instead of December at zero (blue line below is current year), it would just show a blank in matrix and the line graph would stop at November for current year until there is actual data?

 

loafers_0-1670447693180.png

 

1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @loafers ,

 

According to your requirement description, you want to implement 0 for months with no value in the past and blanks for months with no value in the future, right?

If this is the case, you can try modifying this measure to achieve your needs like this:

Measure=
IF(Max('Date'[Date])<eomonth(today,-1)+1,

CALCULATE([Revenue],DATESMTD(DATEADD('Date'[Date],0,MONTH)))+0,blank())

Thank you for your time, if there is a data display problem, you can provide the following .pbix file or data that does not contain sensitive data.

 

Best Regards,

Neeko Tang

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

View solution in original post

2 REPLIES 2
v-tangjie-msft
Community Support
Community Support

Hi @loafers ,

 

According to your requirement description, you want to implement 0 for months with no value in the past and blanks for months with no value in the future, right?

If this is the case, you can try modifying this measure to achieve your needs like this:

Measure=
IF(Max('Date'[Date])<eomonth(today,-1)+1,

CALCULATE([Revenue],DATESMTD(DATEADD('Date'[Date],0,MONTH)))+0,blank())

Thank you for your time, if there is a data display problem, you can provide the following .pbix file or data that does not contain sensitive data.

 

Best Regards,

Neeko Tang

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

amitchandak
Super User
Super User

@loafers , Try like

 

0 between range
Measure = var _1= CALCULATE([Revenue],DATESMTD( 'Calendar'[Date]) )  +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))

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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