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 Designer Desktop Discussions

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

OR condition not working in Filter tool

TarunDeep
8 - Asteroid

How does OR works in Alteryx. Does it take both the conditions in consideration or if one is satisfied then other condition will be skipped?

I am using below condition in filter tool and it is giving only result for the first condition. I am comparing month with month:

 

([Date New] = DateTimeParse('01/'+ ToString( DateTimeMonth(datetimeadd(datetimetoday(),IF DateTimeDay(DateTimeToday())>=1 AND DateTimeDay(DateTimeToday())<=10 THEN -2 ELSE -1 ENDIF,"months")))+'/'+ToString(DateTimeYear(DateTimeToday())),'%d-%m-%Y'))
OR
([Date New] = DateTimeAdd(
DateTimeParse('01/'+ ToString( DateTimeMonth(datetimeadd(datetimetoday(),IF DateTimeDay(DateTimeToday())>=1 AND DateTimeDay(DateTimeToday())<=10 THEN -2 ELSE -1 ENDIF,"months")))+'/'+ToString(DateTimeYear(DateTimeToday())),'%d-%m-%Y'),-1,"months"))

 

The months are in format below:

2017-10-01
2017-11-01
2018-09-01
2018-02-01
2018-03-01
2018-09-01
2018-10-01

 

Thanks!

4 REPLIES 4
jdunkerley79
ACE Emeritus
ACE Emeritus

OR are evaluated lazily - i.e. if the first condition is true second is not evaluated.

 

Looking through your expression I think the issue is that Alteryx is comparing dates with datetimes. These differ due to the trailing 00:00:00.

 

One option is to adjust your expression to remove the trailing time:

([Date New] = Left(DateTimeAdd(Left(DateTimeToday(),8)+"01",IIF(DateTimeDay(DateTimeToday())<=10,-2,-1),"months"), 10))
OR ([Date New] = Left(DateTimeAdd(Left(DateTimeToday(),8)+"01",IIF(DateTimeDay(DateTimeToday())<=10,-3,-2),"months"),10))

Alternatively, a select tool in front of the filter to convert to DateTime will also work

 

Sample workflow attached

jdunkerley79
ACE Emeritus
ACE Emeritus

dupe

TarunDeep
8 - Asteroid

Thanks @jdunkerley79 . Your formula worked. I tried changing the date format but it didn't work (I might have missed the format somewhere). Also I noticed that once I add Date-add function in formula, the filter stopped working. This might again be the formatting issue.

jdunkerley79
ACE Emeritus
ACE Emeritus
Yep datetimeadd always returns a datetimeadd in yyyy-mm-dd hh:mm:ss format.
Labels