Free Trial

Alteryx Designer Desktop Discussions

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

Data capture for prior week

aparna0208
8 - Asteroid

Hi,

 

I have a workflow that I run every Monday and it is for the prior week. For example if I run it on 2021-08-16 then the output needs to include data from 2021-08-09 to 2021-08-15(Mon-Sun). Is there a tool which will enable me to have the dates automatically updated each week to capture the prior week? Also, schedule the workflow to run every Monday?

7 REPLIES 7
cmcclellan
13 - Pulsar

You can create a formula that does this 

 

Yesterday = DateTimeAdd(DateTimeToday(),-1,"day")

Last week = DateTimeAdd(DateTimeToday(),-7,"day")

 

Use that in a filter to compare against the date that you want.

 

To schedule, you need Alteryx Server or the Scheduler option for Designer.

aparna0208
8 - Asteroid

@cmcclellan thank you for the response! Not able to follow this. Should I use both formulas?

apathetichell
19 - Altair

@cmcclellanis explaining the two formula you need in your filter tool (assuming you have your date field in alteryx format dates)... it would be [date]>= datetimeadd(datetimetoday(),-7,"days") and [date]<=datetimeadd(datetimetoday(),-1,"days")

 

 

as far scheduling goes - do you have scheduler? it's fairly straight forward if you do.

aparna0208
8 - Asteroid

@apathetichell Thanks for the explanation! Let me explain my current workflow process and the output I'm getting after I tried this formula along with a logic.

 

The dataset includes a field called created date where it includes all the data and date format is as seen below

 

Created date

2021-08-11 00:12:00

2021-07-01 11:57:00

2021-05-20 00:03:00

2021-08-01 04:00:00

 

I used a input text tool and added two columns as start date and end date and randomly set it from 2021-01-01 to 2021-01-08. Then used two formula tools with below formula

DateTimeAdd(DateTimeToday(), - ToNumber(DateTimeFormat(DateTimeToday(), '%u')) -2 , 'days')
DateTimeAdd([StartDate], 7, 'days')
 
And then use a filter tool to filter dates as created date >=start date and created date <=end date
The problem with this is whenever I run the workflow(yesterday or today) its taking the same date range.
 
I am looking for a process where when I run it the dates should be automatically updated to prior week and give the output.
Not sure if I'm doing anything wrong or is it because I'm trying this formula on Thur/Fri
 
Please help me out with this. Thank you in advance!
jrgo
14 - Magnetar

@aparna0208 

 

You could also just use the Basic filter options as below which I have set up to keep the dates for the last 7 days, excluding today. it's a zero based count hence Number of Periods = 6.

 

jrgo_0-1628892500365.png

 

apathetichell
19 - Altair

@jrgo  - That is some mad knowledge on basic filters.  Great job.

aparna0208
8 - Asteroid

@jrgo @apathetichell Both solutions worked. Thank you so much for your help on this 🙂

Labels
Top Solution Authors