Forum Discussion
create dax YTD 2019
Sylvine_Wyz , with time intelligence and date table
YTD QTY forced=
var _max = today()
return
calculate(Sum('order'[Qty]),DATESYTD('Date'[Date]),'Date'[Date]<=_max)
//calculate(TOTALYTD(Sum('order'[Qty]),'Date'[Date]),filter('Date','Date'[Date]<=_max))
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)
//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,year),'Date'[Date]<=_max)
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184
Appreciate your Kudos.
- Sylvine_Wyz6 years ago
Helper IV
Hello amitchandak !
Thanks for your help !!!The second solution is correct ! 😄
I'm a new in the power bi's practice.
Now, i would like the same until the last month of year N-1.(01/01/2019 to 30/06/2019)
I try this : but it's not correct
var _max = date(year(today()-1),month(today()-1),TODAY())returnCALCULATE(Sum('wyz_reporting bi_order'[quantity_order_line]),DATESYTD(dateadd('Date'[Date],-1,month)),'Date'[Date]<=_max)//TOTALYTD(Sum('order'[Qty]),dateadd('Date'[Date],-1,month),'Date'[Date]<=_max)Can you help me ?Have a nice Day