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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
mra1984
Helper II
Helper II

calculating Last year year to date

LYYTD_2019_particpation =
DIVIDE(
CALCULATE(SUM(raw[Value]),raw[Value/Volume]="Value",raw[Online/TE]="Online",'Calendar'[Date].[Year]=2019),
CALCULATE(SUM(raw[Value]),raw[Value/Volume]="Value",raw[Online/TE]="TE",'Calendar'[Date].[Year]=2019))
 
This is my measure but I need to modify it to do just last year year to date rather than the whole year?  Any ideas? 
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @mra1984 ,

 

You can try EDATE() function, please refer to the measure below.

Measure = CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[date]<=EDATE(SELECTEDVALUE('Table 2'[Date]),-12)&&'Table'[date].[Year]=2019))

 4.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

Not sure you tried datesytd or totalytd or not.

Use them with date calendar

YTD Sales = CALCULATE(SUM(raw[Value]),DATESYTD(('Calendar'[Date]),"12/31"))
Last YTD Sales = CALCULATE(SUM(raw[Value]),DATESYTD(dateadd('Calendar'[Date],-1,Year),"12/31"))

This Sales = CALCULATE(SUM(raw[Value]),DATESYTD((ENDOFYEAR('Calendar'[Date])),"12/31"))
Last YTD complete Sales = CALCULATE(SUM(raw[Value]),DATESYTD(ENDOFYEAR(dateadd('Calendar'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(raw[Value]),DATESYTD(dateadd('Calendar'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(raw[Value]),dateadd('Calendar'[Date],-1,Year))

 

"12/31" is a way to mention where the year will end. So it will take the start of the year based on that

 

v-jayw-msft
Community Support
Community Support

Hi @mra1984 ,

 

You can try EDATE() function, please refer to the measure below.

Measure = CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[date]<=EDATE(SELECTEDVALUE('Table 2'[Date]),-12)&&'Table'[date].[Year]=2019))

 4.PNG

 

Best Regards,

Jay

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
Pragati11
Super User
Super User

Hi @mra1984 ,

 

Check the DAX functions for PREVIOUS YEAR and SAMEPERIODLASTYEAR.

https://docs.microsoft.com/en-us/dax/previousyear-function-dax

https://docs.microsoft.com/en-us/dax/sameperiodlastyear-function-dax

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

yes I am aware but I can you show where in the DAX you would put it to get it to work? 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.