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.

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.

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Top Solution Authors