Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Filter Last 3 days if today is monday

Rahul287
5 - Atom

Hi Everyone,

 

I have workflow that runs daily, on monday its collect the data from friday but the file as data for saturday and sunday as well. i am able to filter the data using 

 

[New COB Date] = ToDate(DateTimeAdd(DateTimeToday(), Switch(DateTimeFormat(DateTimeNow(),'%a'),-1,
'Mon',-3), "days")) 

 

But it does not give me the data from sat and sun.

 

Rahul287_1-1659000907866.png

 

4 REPLIES 4
OllieClarke
16 - Nebula
16 - Nebula

Hey @Rahul287 

I'm assuming your workflow runs every weekday, and you want to collect the previous day's data (except on Monday when you want Fri-Sun)

 

This filter will do that

IF datetimeformat(DateTimeToday(),'%a')='Mon' THEN 
[Date]<DateTimeToday() AND [Date]>=todate(datetimeadd(DateTimeToday(),-3,'day'))
ELSE 
[Date]=todate(datetimeadd(DateTimeToday(),-1,'day'))
ENDIF

 

I've attached a workflow with the filter linked to a field so you can test that it does what you want

OllieClarke_0-1659003451944.png

 

 

Best,

 

Ollie

Rahul287
5 - Atom

Thank for helping with that, but i am trying to understand why does not my formula work it does the same thing.

'

 

 

OllieClarke
16 - Nebula
16 - Nebula

@Rahul287 

Your New COB date is looking back 1 day for all days apart from Monday, which it looks back 4 

OllieClarke_0-1659005053697.png

 

But in your filter, you're saying that this Date is equal to that, so on a Monday, you look back to Friday, but you miss out on Saturday and Sunday. You want your filter to say that the date is greater than or equal to this lookback date, and less than today. Then you'll get all 3 days on Monday, but 1 day on all other days.

 

Ollie

Michael1991
5 - Atom

This solution works well. Thank you!

Labels
Top Solution Authors