cancel
Showing results for
Did you mean:
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
Super User III

``````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] )
)``````
3 REPLIES 3
Super User III

``````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] )
)``````
Helper III

Thank you very much for your help!

Best regards

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.

Announcements

Manage your user group events

Check out the News & Announcements to learn more.

Microsoft named a Leader in The Forrester Wave

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

Power BI Dev Camp - September 30th, 2021

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

Microsoft Learn

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

Top Solution Authors
Top Kudoed Authors