0
votes

How can I build a DAX function which calculates all the data until a certain date and compare that with the previous year which have the same months as the "until" date?

For example, today's date is 5 April 2018, so if I select 2017 year inside the slicer, I should be able to see a graph which shows me the comparison between the start of year i.e 1 Jan 2018 to 5 April 2018, and 1 Jan 2017 to 5 April 2017 with the previous year.

Currently I am using YtD, but I think it's calculating all the 12 months of data of all the years except the year 2018, where it shows me data from Jan 1 to April 5. Can anyone shed some light here?

Currently I am using this YTDQty = TOTALYTD(sum(Bookscan[QtySold]),DATESYTD(Bookscan[Week Date]))

Which is showing me correct data of 2018, till date, I should be able to compare the 4 months of data to my previous years 2017, 2016, 2015, these years are showing me total data for all the years i.e 12months of data, However I only need to see data start from 2018 Jan till todays date or let say March 1, so all the years should show me this current data how to do this?

1
Please try to format your posts readably instead of just posting an impenetrable stream of consciousness. Anyway, if you have a problem with your current code, you should show it, not just vaguely describe it.underscore_d
YTDQty = TOTALYTD(sum(Bookscan[QtySold]),DATESYTD(Bookscan[Week Date])) this is the code which I am using but not able to get the previous years date till todays date.deadtest
Please edit your question to include that and any other relevant info; comments should only be for non-essential addenda or discussion.underscore_d

1 Answers

0
votes

Very similar to this question.

Do you have a Date Dimension in your model?

TotalQuantity = 
SUM(Bookscan[QtySold])

TotalQuantity YTD =
TOTALYTD([TotalQuantity],'Date'[Date])

TotalQuantity YTD LY =
CALCULATE(
    [TotalQuantity YTD],
    SAMEPERIODLASTYEAR('Date'[Date])
)