Forum Discussion
DATESYTD not working ?
- 4 years ago
Hi,
If I understood your problem correctly you would like to have YTD measure in a KPI card or something similar to that? Based on the problem description I think your slicer selection is not working as you would hope and thus you get the blank value. Instead of Datesytd you could use the following approach:
My test data:Ideal outcome:
So in this example the goal is that without any slicers the YTD measure would return 350. That is this year's running total until today. If something is selected the calculation should be done until the selected day. So for example If I select 4.12.2021 the calculation would be from this time period: 1.1.2021-4.12.2021.
Measure using datesbetween ([Base measure] is just SUM of [Value]):YTD from base =var test = HASONEFILTER(YTD_Example[Date])var _sdate = if(test,DATE(YEAR(SELECTEDVALUE(YTD_Example[Date])),1,1), DATE(YEAR(TODAY()),1,1))var _edate = if(test,MAX(YTD_Example[Date]),TODAY()) returnCALCULATE([Base measure],DATESBETWEEN(YTD_Example[Date],_sdate,_edate))End result:
Without selection (calculates until today):With date selected (calculates until selection:
Hopefully this can be used to resolve your issue and if it does accept this as a solution!
Hi admin_xlsior
You need to add a Calendar [Date] table to your model to use time intelligence DAX functions.
Use this link to add that calendar: https://www.vahiddm.com/post/creating-calendar-table-with-3-steps
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: www.linkedin.com/in/vahid-dm/