Forum Discussion
DAX YTD
Hi all.
I am trying to compare Sales YTD vs. Planned Sales YTD.
Planned Sales are distributed over this year till 31/12.
Struggling to apply YTD DAX for planned data. It looks like it applies MTD since it gives only part of Feb again sums the rest of the months.
Could you advise? Used this formula: YTD PLAN = CALCULATE([Total_2020 PLAN],DATESYTD(DIM_CALENDAR[Date]))
Example attached:
YTD PLAN =
var _min = date(year(today()),1,1)
return
CALCULATE(Plan_2020[Sum_2020 PLAN], FILTER(all(Plan_2020), (Plan_2020[date])>=_min && (Plan_2020[date]) < TODAY()))But prefer to it like this after having date table
YTD PLAN =
var _min = date(year(today()),1,1) //start of year
return
CALCULATE(Plan_2020[Sum_2020 PLAN], FILTER(all(DATE), (DAte[date])>=_min && (Date[date]) < TODAY()))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/
6 Replies
- amitchandak
Super User
The formula seems right. Unless you have done some date calculation in [Total 2020 plan].
Also is joined to date in the calendar or some other column.
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Proud to be a Datanaut Connect on Linkedin- AnonymousNot applicable
Thank you for your response.
Total 2020 plan is just a measure for sum of 2020 PLAN.
Not entirely sure what you mean by "Also is joined to date in the calendar or some other column.". Could you please elaborate on that?
Thank you!
- amitchandak
Super User
Can you share the relationship diagram with join field highlighted and your calculated formulas
- V-lianl-msft
Community Support
Hi Anonymous ,
Has [total 2020 plan] calculated sales? You should change this field to an un aggregated sales field.
If the problem persists,could you please share sample data or sample pbix?(Please mask any sensitive data before uploading)
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.