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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
RichardJ
Responsive Resident
Responsive Resident

Missing part of line : might need measure with PREVIOUSMONTH and IF to find value but not sure

Hi,

Looking at the following two charts, we can see the lower one has a gap between March and April in the area shown.

 

Power_BI_Question.JPG

 

I'd like to show the missing element in the lower chart but unfortunately it isn't available within my source data.

Power_BI_Question_Data.JPG

 I've been trying to use an IF statement to determine if the PREVIOUSMONTH = 0 then use the value from the 'Spent' column as the start point for the line but am struggling to do so.

 

The source excel file and the pbix files can be found via this link.

It isn't possible to change the source data.

 

Anyone got any ideas or the best way to approach this one so that I can get the lower chart to look like the top chart (and still not show a line for the Jan/Feb months despite them being 0 also)?

 

Thanks,

Richard

1 ACCEPTED SOLUTION

@RichardJ here you go

 

Remaining Measure = 
VAR __minDate = 
CALCULATE ( 
    MIN ( 'Power_BI_Feed_Data Set B'[Date] ), 
    ALLSELECTED(), 
    'Power_BI_Feed_Data Set B'[Remaining] <> BLANK()  
) 
VAR __lastMonth = EOMONTH ( __minDate, -1 )
VAR __lastMonthSpent = CALCULATE ( SUM ( 'Power_BI_Feed_Data Set B'[Spent] ), EOMONTH ( 'Power_BI_Feed_Data Set B'[Date], 0 ) = __lastMonth ) 
RETURN
SUM( 'Power_BI_Feed_Data Set B'[Remaining] ) + 
IF ( EOMONTH ( MAX ( 'Power_BI_Feed_Data Set B'[Date] ), 0 ) = __lastMonth, __lastMonthSpent )

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@RichardJ use following measure for remaining instead of direct column

 

Remaining Measure = SUM( 'Power_BI_Feed_Data Set B'[Remaining] ) + 0

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

RichardJ
Responsive Resident
Responsive Resident

Thanks for taking the time to respond @parry2k but the measure you are suggesting shows the line as follows where i'd like the line to meet the top of the March column plus not show any line for the January and February months

 

Power_BI_Question_parry2kresponse.JPG

 

@RichardJ try this measure

 

Remaining Measure = 
VAR __minDate = 
CALCULATE ( 
    MIN ( 'Power_BI_Feed_Data Set B'[Date] ), 
    ALLSELECTED(), 
    'Power_BI_Feed_Data Set B'[Remaining] <> BLANK()  
) 
VAR __lastMonth = EOMONTH ( __minDate, -1 )
RETURN
SUM( 'Power_BI_Feed_Data Set B'[Remaining] ) + 
IF ( EOMONTH ( MAX ( 'Power_BI_Feed_Data Set B'[Date] ), 0 ) = __lastMonth, 0 )

 

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

RichardJ
Responsive Resident
Responsive Resident

So close. Nice approach and not one i'd thought of.  Thanks @parry2k .
Is there any way I can extract the value for the previous month(March) and add it to the zero value so that the line starts at the top of the bar? 

 

Power_BI_Question_parry2kresponse2.JPG

 

@RichardJ here you go

 

Remaining Measure = 
VAR __minDate = 
CALCULATE ( 
    MIN ( 'Power_BI_Feed_Data Set B'[Date] ), 
    ALLSELECTED(), 
    'Power_BI_Feed_Data Set B'[Remaining] <> BLANK()  
) 
VAR __lastMonth = EOMONTH ( __minDate, -1 )
VAR __lastMonthSpent = CALCULATE ( SUM ( 'Power_BI_Feed_Data Set B'[Spent] ), EOMONTH ( 'Power_BI_Feed_Data Set B'[Date], 0 ) = __lastMonth ) 
RETURN
SUM( 'Power_BI_Feed_Data Set B'[Remaining] ) + 
IF ( EOMONTH ( MAX ( 'Power_BI_Feed_Data Set B'[Date] ), 0 ) = __lastMonth, __lastMonthSpent )

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

RichardJ
Responsive Resident
Responsive Resident

Fixed. Thanks for the lesson @parry2k. Appreciate you taking the time.

 

Fixed.JPG

@RichardJ it will show something like this

 

image.png

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.