Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
globalwarme
Frequent Visitor

dynamic time shifting

I am working with a group of public traded companies all with different year ends.  For example Apple's last year-end was September 30, 2020 while Target's was Jan 31, 2021.  I am trying to build a measure that will dynamically allow me to pull in a series of year ends for both companies.  The last year end I can handle with the LASTYEAR function, but I am having trouble dynamically pulling in dates for previous years.  PREVIOUSYEAR and DATEADD functions don't seem to work because they key off of my dateDim table, which can't tell between different year ends.  What I need to be able to do is move back one and two years from the LASTYEAR value, but can't seem to find a way to do this.  For example, my LASTYEAR value for Apple is September 30, 2020 and for Target is Jan 31, 2021 as expected.  But my previous year value for Apple is still September 20, 2020, which is not correct, while the previous year value for Target is correct.  Not sure how to handle this.  Any ideas how to handle this dynamically.  Many thanks

2 REPLIES 2
Anonymous
Not applicable

@globalwarme 

 

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.

globalwarme_0-1617844474824.png

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.

globalwarme_2-1617845713533.png

 

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors