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

contains multiple strings?

becki
8 - Asteroid

i read this - https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Filter-on-Multiple-Contains/m-p/309402

 

but what i need is something like :

 

contains([field1], "mustang" or "fiesta" or "f150") to change a set of values, based on the value of a field, in this case, the nameplate field or do i have to do:

Contains([field1],"mustang") OR

Contains([field1]),"fiesta")

 

thanks

 

7 REPLIES 7
tcroberts
12 - Quasar

You could instead use something like:

 

REGEX_Match([Field1], 'mustang|fiesta|f150')

Let me know if you have more questions about building the regex, or if this doesn't work for you.

 

Cheers!

becki
8 - Asteroid

thanks.  can you use that with a formula tool so I can change the value of the field [wheelbase] based on values in the field [nameplate]?  thanks

 

becki
8 - Asteroid

REGEX_Match([nameplate],"Mustang"|"Figo") doesn't work, even If I use 'Mustang' or double quotes.  the error , in the formula tool is "unknown operator "|", did you mean "||"? and if I put that in, then I can't change the field "wheelbase" in formula since it's a numeric. 

tcroberts
12 - Quasar

Yes, you'd want to enter an expression something like:

 

IF REGEX_Match([Field1], 'mustang|fiesta|f150')
THEN Value1
ELSE Value2
ENDIF

This should do what you want. If you can provide a sample of data I could try to put an actual example together.

 

Let me know if you need further help setting this up.

tcroberts
12 - Quasar

You want the | character inside the quotes. 

 

The second argument should be a single string, with things you want to look for separated by |.

 

The | (pipe operator) is used to mean the logical OR operation.

becki
8 - Asteroid

thanks!  and duh, I need to read for context not for speed! 

JFurda
8 - Asteroid

This does not appear to be working for me in a formula tool. It works with a single argument, but when I put in multiple arguments, it does not work (does not change the value upon a match/true result)
Output Column: FIELD2


IF(Contains([FIELD1], '2366|2302'))
THEN "N"
ELSE [FIELD2]
ENDIF

 

I'm using Contains() because the value in the FIELD1 could have a leading zero or even additional text.

 

What am I missing? 

Labels