cancel
Showing results for 
Search instead for 
Did you mean: 
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
Carousel_PBI_Wave1

2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

Power BI Summit Carousel 2

Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

BizApps LATAM 2023

Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

Power Platform Bootcamp

Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors