community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Date Filter based on Specific Condition

Meteor

Hi All, 

 

 

I need to a filter a date 2 days ahead of today excluding Weekends. For example, If today is Monday then i need to get Wednesday date. If today is Thursday i need to get Monday or if its Friday i need to get Tuesday. 

 

Appreciate if anyone can provide the formula for the above use case. 

 

 

Thanks,

Rob

Alteryx Certified Partner

Hi Rob, 

 

I don't have a simple formula for you - but I have 3 tools that can get the job done. 

 

By generating rows for every day of the next week, and then filtering out weekends we can then sample for the next two days. 

 

Spoiler
flow.png

The workflow is attached

Meteor

Thanks for the reply @lmorrell  but the solution you provide is not requirement for my use case. 

 

Just to rephrase my use case,  i want to a apply a logic wherein if today is Monday then it will give data that has date as of Wednesday which 2 days different. But if today is Thursday or Friday i need to get the data with date as of Monday and Tuesday  the following week. 

Alteryx Certified Partner

Hi @rdelmund 

 

This should do the trick:

 

 

IF DateTimeFormat([Date],'%A') IN ("Thursday", "Friday") THEN DateTimeAdd([Date],4,"days") ELSE DateTimeAdd([Date],2,"days") ENDIF

 

 

You didn't specify what to do if the original date is a weekend so I've applied the standard +2 days logic. I'm guessing your source data perhaps doesn't include weekends so it's a moot point.


Example workflow attached. The "DayofWeek" columns are just there for illustrative purposes.

 

Screenshot 2019-07-22 at 09.42.58.png

Labels