Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Getting difference from current date to look back day.

Inactive User
Not applicable

I am looking to create a date difference formula which will look back 90 days/160 days/365 days from each date and subtract the data from that date. Also if the look back day is a Sunday, then it should pick up the data for Monday else if the look back day is Saturday then the formula should pick the data for Friday. I need the final price difference based on the look back logic. The below example is for 90 days look back.

 

Sr.ProductNew PriceDateLook back 3 monthsLook back dayLogic to be implementedPrice Difference
1A105/1/2020DateTIMEAdd(ToDate([DATE]),-90,"days") = 02/01/2020SundayIf look back day is Sunday, then take data for the next day i.e. Monday10-101
2A205/2/2020DateTIMEAdd(ToDate([DATE]),-90,"days") = 02/02/2020Monday 20-101
3A305/3/2020DateTIMEAdd(ToDate([DATE]),-90,"days") = 02/03/2020Tuesday 30-102
4A405/4/2020DateTIMEAdd(ToDate([DATE]),-90,"days") = 02/04/2020Wednesday 40-103
5A505/5/2020DateTIMEAdd(ToDate([DATE]),-90,"days") = 02/05/2020Thursday 50-104
6A605/6/2020DateTIMEAdd(ToDate([DATE]),-90,"days") = 02/06/2020Friday 60-105
7A705/7/2020DateTIMEAdd(ToDate([DATE]),-90,"days") = 02/07/2020SaturdayIf Look back day is Saturday, then take data for the previous day i.e. Friday70-105
        
Historical Data       
Sr.ProductOld PriceDateDay   
1A100 02/01/2020Sunday   
1A101 02/02/2020Monday   
1A102 02/03/2020Tuesday   
1A103 02/04/2020Wednesday   
1A104 02/05/2020Thursday   
1A105 02/06/2020Friday   

 

3 REPLIES 3
markcurry
12 - Quasar

The attached workflow should point you in the right direction...

 

 

Inactive User
Not applicable

@markcurry- Thank you for the solution. I did some modification to your solution and it worked out great.

 

Cheers!

Inactive User
Not applicable

I am trying to create a difference of price between the two dates but the workflow is not giving me the expected price difference.

Labels