Inspire EMEA 2022 On-Demand is live! Watch now, and be sure to save the date for Inspire 2023 in Las Vegas next May.
Announcement | We'll be doing maintenance between 2-3 hours, which may impact your experience. Thanks for your patience as we work on improving the community!
alteryx Community

# Alteryx Designer Discussions

SOLVED

## Return last three days data if today is Monday

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
22 - Nova

_

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

Hope that helps,

Angelos

8 - Asteroid

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

Thank you.

22 - Nova

Hi @stj1120

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

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.

Hope this helps 🙂

8 - Asteroid

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.

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

Labels