Alteryx Designer Desktop Discussions

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

regex match on multiple fields for multiple values

Idyllic_Data_Geek
8 - Asteroid

Is it possible to do a regex_match of mutiple fields containing multiple keywords?

 

 

For e:g can I do . if REGEX_Match([Field 1] or Field 2],".*REALTY.*|.*GROUP.*|.*COLLECTION.*|.*SOCIETY.*") instead of writing if else if?

10 REPLIES 10
atcodedog05
22 - Nova
22 - Nova

Hi @Idyllic_Data_Geek 

 

You cant use multiple fields in Regex_Match() you would need to use multiple Regex_Match() with And/Or

Jean-Balteryx
16 - Nebula
16 - Nebula

Hi @Idyllic_Data_Geek ,

 

You can use AND/OR keywords if you need to combine two regex conditions.

apathetichell
18 - Pollux

just write this: 

 

REGEX_Match([Field 1],".*REALTY.*|.*GROUP.*|.*COLLECTION.*|.*SOCIETY.*") or REGEX_Match([Field 2],".*REALTY.*|.*GROUP.*|.*COLLECTION.*|.*SOCIETY.*")

 

That will give you what you want if you put in a formula tool (new column type boolean) or you can use it as-is in a filter tool. If that doesn't work and it's enough data - transpose it and use the regex_match formula with [vaue] as your field.

atcodedog05
22 - Nova
22 - Nova

Hi @Idyllic_Data_Geek 

 

You mentioned, " instead of writing if else if?" Can you provide more info on the usecase so that we can help you out.

Idyllic_Data_Geek
8 - Asteroid

IF REGEX_Match([Field 1],".*REALTY.*|.*GROUP.*|.*COLLECTION.*|.*SOCIETY.*")  THEN 'ENT'

ELSE IF REGEX_Match([Field 2],".*REALTY.*|.*GROUP.*|.*COLLECTION.*|.*SOCIETY.*") THEN 'ENT'

ELSE 'IND'

ENDIF

atcodedog05
22 - Nova
22 - Nova

Hi @Idyllic_Data_Geek 

 

Since you want to check in either of them and you want to use single regexmatch() you can concat the text fields like below. That would create a single concat variable on which match can be applied.

 

 

REGEX_Match([Field 1] +"-"+ [Field 2],".*REALTY.*|.*GROUP.*|.*COLLECTION.*|.*SOCIETY.*")

 

IF REGEX_Match([Field 1] +"-"+ [Field 2],".*REALTY.*|.*GROUP.*|.*COLLECTION.*|.*SOCIETY.*") THEN 'ENT'

ELSE 'IND'

ENDIF

 

Hope this helps : )

Idyllic_Data_Geek
8 - Asteroid

How to calc the below...

if a = 'Text without any spaces' then 'ENT'

 Thanks in advance!

atcodedog05
22 - Nova
22 - Nova

Hi @Idyllic_Data_Geek 

 

This would be the formula

 

IF REGEX_Match([^\s]+) THEN 'ENT'

ELSE 'IND'

ENDIF

 

Hope this helps : )

If above responses helps please don't forget to mark it as solution.

Idyllic_Data_Geek
8 - Asteroid

where in this calc will I plug in the field that I'm using for calc?

Labels