Can anybody suggest how to write YTD Sales formula in DAX that can be used (e.g. in Excel Pivot Table) with Year on column, to compare YTD sales over the last few years.
Specifically, my difficulty is in determining "as of date". If I refer to the Date
table without removing the filter, then something like LASTNONBLANK('Date'[Date],[SalesAmount])
will give me 12/31
of the corresponding year for prior year's columns. And if I remove the Date filter via ALL()
I will get the last available date, thus ignoring filters/slicers a user may have added.
I am fairly new to DAX, and was hoping that this was a common scenario that someone has already solved. But all I am finding are the solutions for YTD comparison with prior year, NOT YTD "trend" over multiple years.
Any feedback is really appreciated!
Vlad