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 Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

Get Ready for Power BI Dev Camp

Power BI Dev Camp - September 30th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Top Solution Authors