Forum Discussion

colverjustin's avatar
colverjustin
Frequent Visitor
3 years ago

DATEADD not fully working

Hello!

 

I have a table with 3 columns, Booking Date, Holiday Year, Sales Value.  

 

For example, Holidays in 2023 might be booked in the couple of years before the holiday.

 

I want to use DATEADD to adjust the booking date by years, but where the number of years is dependent on the Holiday Year. 

 

I created the following formula, which is nearly working:

 

Adjusted Sales = CALCULATE( [Sales] , DATEADD( [Booking Date] , (MAX('Data'[Holiday Year])-2023),  YEAR) )

 

 

So Holidays in 2023 have no adjustment. Holidays in 2022 have the booking date moved forward 1 year. Etc, etc.

 

This is working mainly, but I'm ending up with a table like the below. It is great for Holiday Years from 2020, but before then, its giving me the correct totals but there are no sales in the individual booking dates.

 

 

Holiday year >>> 2017201820192020202120222023
Booking year (below)       
2021---7m2m1m5m
2022---9m4m7m10m
2023---9m1m3m7m
TOTAL5m4m10m26m6m11m22m

 

 

I've tried replacing the formula as below, as a test for 2019, and it works fine!

Adjusted Sales = CALCULATE( [Sales] , DATEADD( [Booking Date] , -4,  YEAR) ) 

 

 

Any idea what could be causing the problem?

 

Thanks so much!

 

Justin

1 Reply