Inspire EMEA 2022 On-Demand is live! Watch now, and be sure to save the date for Inspire 2023 in Las Vegas next May.
We'll be completing standard maintenance for our Single Sign-On system on November 30th 6pm Pacific Time for approximately one hour. During this time My Alteryx and sign-in functionality to all My Alteryx programs (Licensing Portal, Community, Beta Program, Case Portal, and others) may be inaccessible. Thank you for your patience.

Alteryx Designer Discussions

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

Return last three days data if today is Monday

stj1120
8 - Asteroid

Hi all,

 

I need to show the results that are generated on Friday, Saturday and Sunday on monday. Then for the other days from Tuesday to till Friday I need to show the previous day data. 

 

I tried the below formula but, no luck.

 

IF DateTimeFormat(DateTimeToday(), "%a") = "mon"
THEN DateTimeDiff(DateTimeFormat(DateTimeToday(), "%Y-%m-%d"),DateTimeFormat([Date],"%Y-%m-%d"),"days")<4
ELSE DateTimeFormat([Date],"%Y-%m-%d") = DateTimeFormat(DateTimeAdd(DateTimeToday(), -1, "days"), "%Y-%m-%d")
ENDIF

 

Please check and help how to achieve this. 

 

Thank you.

 

Best Regards,

Teja.

7 REPLIES 7
atcodedog05
22 - Nova
22 - Nova

_

AngelosPachis
16 - Nebula

Hey @stj1120 ,

 

You can use a filter tool with the following expression 

 

IF Datetimeformat(DateTimeToday(),"%a")="Mon"
// check if day workflow runs is Monday
 THEN (DateTimeDiff(DateTimeToday(),Datetimetrim([DateTime],"days"),"days")>=1 
AND DateTimeDiff(DateTimeToday(),Datetimetrim([DateTime],"days"),"days")<=3)
//keep previous 1 to 3 days
ELSE DateTimeDiff(DateTimeToday(),Datetimetrim([DateTime],"days"),"days")=1
//keep previous day
ENDIF

 

Dateteimdiff functions find the days between todays date and  previous days and the Datetimetrim function trims all days to midnight. So today is the 1st of June, but if you had a record for the 31 of May 23:59:50 you would like to show that record because it is in the previous day, although technically 24 hours have not gone by

 

AngelosPachis_0-1622527839058.png

 

Hope that helps,

 

Angelos

stj1120
8 - Asteroid

Hi @atcodedog05 

 

I have attached the output file. Please check and help.

 

Thank you. 

atcodedog05
22 - Nova
22 - Nova

Hi @stj1120 

 

@AngelosPachis has provided a approach which should work for your usecase 🙂

atcodedog05
22 - Nova
22 - Nova

Hi @stj1120 

 

I made some slight change to accommodate your existing fields and show you the variation. Just remove the // in front of datetimetoday() in today formula and remove the manually set date for running in the actual scenario.

atcodedog05_0-1622529055513.png

 

Hope this helps 🙂

 

 

stj1120
8 - Asteroid

hi @AngelosPachis 

 

Thank you for your quick reponse.

 

But unfortunately, it is not working when we have the complete data. 

 

I have included the dates until yesterday. Could you check once and help?

 

Thank you. 

 

AngelosPachis
16 - Nebula

Hi @stj1120 ,

 

Can you elaborate more when you say it's not working? Today is Tuesday, so we should keep only records for the previous day. Yesterday was Monday the 31st of May, and this falls out of the T output anchor

 

AngelosPachis_0-1622530514180.png

 

Labels