Forum Discussion
dynamic time shifting
I can't say your description is clear. Please give us a concrete example as close to the reality as possible. Best, explaining this with DAX and visuals.
OK here is the Table (working in power pivot) with the date field representing the last reported fiscal year end for the companies. Notice they are all different.
I am trying to create a dynamic reporting table that pulls in the right reporting dates for each company which will include last reported date and previous year, previous year + 1, previous year +2, etc.
I can't just selct for the year, because as you will notice the last reported years don't match - for Walmart and Target the last reported year is 2021, but for Costco it is 2020. This also complicates things when I try to use the PREVIOUSYEAR or DATEADD - 1 function. The LASTDATE function produces the correct value for all of them, but when I try to shift back one year, it doesn't work (for Costco), because I have to key off of the DateDim table.
Here is the DAX
lastDate = LASTDATE([incomeStatement[date])
and then for the previous year I used:
PY = CALCULATE([lastDate], DATEADD(dateDim[date], -1, YEAR))
I hope this clarifies my problem.
Thanks again,
P