Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Syntax Assistance for Filter Function

GaryPei
5 - Atom

Hello,

 

When I was attempting to filter based on complex "and/or" statements, I get different (incorrect) results than if I separate the items out into two separate filters. I think there may be an error in what I have for the complex filter.

 

Single complex filter only gave me the results where descr= lmn and PO Descr = 123:

([descr] = 'ABC'
or [descr] = 'cde'
or [descr] = 'fgh'
or [descr] = 'ijk'
or [descr] = 'lmn'
or [descr] = 'opq'
or [descr] = 'rst')
and contains([PO Descr], '123')

 

When I separate it out into two filters, I got the expected results. The first of the two filters:

([descr] = 'ABC'
or [descr] = 'cde'
or [descr] = 'fgh'
or [descr] = 'ijk'
or [descr] = 'lmn'
or [descr] = 'opq'
or [descr] = 'rst')

The second of the two filters (filtered subsequently on the "true" of the above):

contains([PO Descr], '123')

 

Any help is greatly appreciated.


Thanks.

 

2 REPLIES 2
jrgo
14 - Magnetar

@GaryPei

 

I believe they would all just be OR's

 

[descr] = 'ABC'
or [descr] = 'cde'
or [descr] = 'fgh'
or [descr] = 'ijk'
or [descr] = 'lmn'
or [descr] = 'opq'
or [descr] = 'rst'
or contains([PO Descr], '123')

Another option to clean it up would be

 

[descr] IN('ABC', 'cde','fgh','ijk','lmn','opq','rst')
or contains([PO Descr], '123')
GaryPei
5 - Atom

The 'IN' function helped. It was definitely an 'AND' that I wanted to connect the first set of statements to the second. Any of the items in the first set AND where the second set is also true.

 

I am not sure why the syntax I had wouldn't work, maybe the complexity (number of AND/OR statements) caused an issue? But the 'IN' function seemed to have solved it.

 

Thanks.

 

Labels