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

Year to Date last year

Hi I am using the working formula below to calculate our YTD turnover.

 

YTD_2020 = CALCULATE(SUM('FACTVERKOOP_ALL'[BRUTO_OMZET]);YEAR('FACTVERKOOP_ALL'[DATE])=YEAR(TODAY()))

 

What formula can I use to get the result for the year before?

 

Many thanks in advance

1 ACCEPTED SOLUTION
Super User IV
Super User IV

@BartVlek , With a date table

 

LYTD QTY = TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year))

 

LYTD QTY forced=
var _max = date(year(today())-1,month(today()),day(today()))
return
CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)

 

or

LYTD QTY forced=
var _max = date(year(today())-1,month(today()),day(today()))
return

if('Date'[Date]<=_max,CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year))), blank())

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

2 REPLIES 2
Super User IV
Super User IV

@BartVlek , With a date table

 

LYTD QTY = TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year))

 

LYTD QTY forced=
var _max = date(year(today())-1,month(today()),day(today()))
return
CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)

 

or

LYTD QTY forced=
var _max = date(year(today())-1,month(today()),day(today()))
return

if('Date'[Date]<=_max,CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year))), blank())

 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

@BartVlek 

var maxyear = YEAR(TODAY())

YTD_2020 = CALCULATE(SUM('FACTVERKOOP_ALL'[BRUTO_OMZET]);YEAR('FACTVERKOOP_ALL'[DATE])=maxyear)

and you can use the same substratct one to geet last year

 

var maxyear = YEAR(TODAY())

LYTD_2019 = CALCULATE(SUM('FACTVERKOOP_ALL'[BRUTO_OMZET]);YEAR('FACTVERKOOP_ALL'[DATE])=maxyear-1)

 

And to confirm are you looking for Full year else the same dates available in latest year with the last year?

 

If you think this is helpful please Accept this as Solution and leave a like.

 

Regards, 

Manikumar

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

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

Top Solution Authors
Top Kudoed Authors