cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
EZV12
Helper III
Helper III

Formula PREVIOUSMONTH & DATESYTD

Hello,

I have an issue with the combinasion of formulas PREVIOUSMONTH & DATESYTD. I need the YTD Sum of previous month's value & current month's value.  Here below are the formulas:
 
Sum Inventory PreviousMonth = CALCULATE ([Sum Inventory], PREVIOUSMONTH('Calendar'[Date])) 
Sum Inventory PreviousMonth YTD = CALCULATE([Sum Inventory PreviousMonth], DATESYTD( 'Calendar'[Date] ))
 
The result of "Sum Inventory PreviousMonth YTD" is not correct, there is only the value of previous month instead of the YTD SUM of value of previous month & value of current month.
 
Can anybody help?
Thanks and best regards
1 ACCEPTED SOLUTION
CNENFRNL
Super User III
Super User III

Your measure,

Sum Inventory PreviousMonth YTD =
CALCULATE( [Sum Inventory PreviousMonth], DATESYTD( 'Calendar'[Date] ) )

=
CALCULATE(
    CALCULATE( [Sum Inventory], PREVIOUSMONTH( 'Calendar'[Date] ) ),
    DATESYTD( 'Calendar'[Date] )
)

obviously, inner filter PREVIOUSMONTH overrides outer DATESYTD.

 

You may want to try,

=
CALCULATE(
    CALCULATE( [Sum Inventory], DATESYTD( 'Calendar'[Date] ) ),
    PREVIOUSMONTH( 'Calendar'[Date] )
)

View solution in original post

3 REPLIES 3
CNENFRNL
Super User III
Super User III

Your measure,

Sum Inventory PreviousMonth YTD =
CALCULATE( [Sum Inventory PreviousMonth], DATESYTD( 'Calendar'[Date] ) )

=
CALCULATE(
    CALCULATE( [Sum Inventory], PREVIOUSMONTH( 'Calendar'[Date] ) ),
    DATESYTD( 'Calendar'[Date] )
)

obviously, inner filter PREVIOUSMONTH overrides outer DATESYTD.

 

You may want to try,

=
CALCULATE(
    CALCULATE( [Sum Inventory], DATESYTD( 'Calendar'[Date] ) ),
    PREVIOUSMONTH( 'Calendar'[Date] )
)

View solution in original post

Thank you very much for your help!

Best regards

parry2k
Super User III
Super User III

@EZV12 why you are using the Previous month measure in DATESYTD why not just do 

 

CALCULATE ([Sum Inventory], DATESYTD('Calendar'[Date])) 

 

What you are trying to achieve?






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
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors
Top Kudoed Authors