Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

date ranges: best tool for defining rolling 8 weeks

dkgoydan
5 - Atom

The output I want is bucketed into weeks, I want the last 8 weeks worth of data using a dynamic formula to define the weeks.

Which tool would I use or what syntax should I use to get the data bucketed like this?

 

last week (BETWEEN ((DATE - 1) - 6) AND (DATE - 1)
week -2 (BETWEEN ((DATE - 1) - 13) AND (DATE - 7)
week -3 (BETWEEN ((DATE - 1) - 20) AND (DATE - 14)
week -4 (BETWEEN ((DATE - 1) - 27) AND (DATE - 21)
week -5 (BETWEEN ((DATE - 1) - 34) AND (DATE - 28)
week -6 (BETWEEN ((DATE - 1) - 41) AND (DATE - 35)
week -7 (BETWEEN ((DATE - 1) - 48) AND (DATE - 42)
week -8 (BETWEEN ((DATE - 1) - 55) AND (DATE - 49)

3 REPLIES 3
ShankerV
17 - Castor

Hi @dkgoydan 

 

Step 1: Use the Datetimenow() in formula tool to get the current date.

Step 2: Then create column D1 using datetimeadd tool to subtract the date from current date using formula tool ((DATE - 1) - 6) 

Step 3: Then create column D2 using datetimeadd tool to subtract the date from current date using formula tool (DATE - 1)

Step 4: Use the multirow formula tool to create for next 7 times

Step 5: Create a dynamic formula using the created dates dynamically based on the Datetimenow()

 

If you believe your problem has been resolved. Please mark helpful answers as a solution so that future users with the same problem can find them more easily!!!!

 

Many thanks

Shanker V

ShankerV
17 - Castor

Hi @dkgoydan 

 

Please find the below expected result which will work dynamically for the date run on the current day.

 

ShankerV_0-1671222038211.png

 

ShankerV_1-1671222054871.png

 

Note: The workflow used to achieve the solution is attached which can be downloaded to see how the solution works.

 

If you believe your problem has been resolved. Please mark helpful answers as a solution so that future users with the same problem can find them more easily!!!!

 

Many thanks

Shanker V

 

 

ShankerV
17 - Castor

Hi @dkgoydan 

 

Breaking down my solution for explaining how my solution works dynamically.

 

Date time tool is used to take the current date.

ShankerV_0-1671222231514.png

 

 

Record ID and Generate rows are used to create 8 rows.

ShankerV_1-1671222271174.png

 

Formula tool is used to create -7days and -1days.

 

ShankerV_2-1671222325890.png

 

Multirow tool is used to create the -7 and -1 applied for all the remaining rows.

ShankerV_3-1671222364709.png

 

 

Cross tab and Transpose tool are used to convert from columns to rows, so that I can apply the formula.

ShankerV_4-1671222417785.png

 

 

ShankerV_5-1671222431580.png

 

The dynamic weeks created are appended to the input.

ShankerV_6-1671222475969.png

 

The formula is applied based on the dynamic dates created.

ShankerV_7-1671222512130.png

 

Here is out result.

ShankerV_8-1671222557470.png

 

Note: The workflow used to achieve the solution is attached which can be downloaded to see how the solution works.

 

If you believe your problem has been resolved. Please mark helpful answers as a solution so that future users with the same problem can find them more easily!!!!

 

Many thanks

Shanker V

 

 

Labels