Forum Discussion
YTD LY Calculation not working
Hi,
I cannot figure out why my YTD LY calculation is not working. Can someone take a look and help me? I would expect to see the same value in August - December for the YTD Sale LY calculation but it is continuing to add values it should stop adding values in July. I want to compare the same period this year compare to the same period last year.
Here are my calculations.
2 Replies
- amitchandak
Super User
kg4u , You have control that
examples
LYTD QTY forced=
var _max = date(year(today())-1,month(today()),day(today()))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)
LYTD QTY forced=
var _today = maxx(allselected('Order'),'order'[Date])
var _max = date(year(_today)-1,month(_today),day(_today))
return
if(max('Date'[Date])<=_max, CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max), blank())
//OR
//CALCULATE(Sum('order'[Qty]),DATESYTD(dateadd('Date'[Date],-1,year)),'Date'[Date]<=_max)
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)comments // are an alternate formula for return
- kg4u
Helper II
I am trying to use your examples, which I am very thankful for. However, they are giving me an error.
Seems that I am not using MAX correctly, please advise.