Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Simplify IF statement with Contains

hellyars
13 - Pulsar

How can I convert the expression below (that works) to something like this:  

 

if Contains ([FileName],("78","36","13","20","04")) then "X" else "A" endif 

if Contains([FileName],"78") then 'X'
elseif Contains([FileName],"36")  then 'X'
elseif Contains([FileName],"13")  then 'X'
elseif Contains([FileName],"20")  then 'X'
elseif Contains([FileName],"04")  then 'X'
elseif Contains([FileName],"04")  then 'X'
else "A"
endif 

 

1 REPLY 1
Maskell_Rascal
13 - Pulsar

Hey @hellyars 

 

You can use a Regex_CountMatches formula to simplify the If statement. 

 

IF REGEX_CountMatches([FileName], "78|36|13|20|04")=1 THEN "X" ELSE "A" ENDIF

 

 

Maskell_Rascal_0-1611779740016.png

 

If this solves your issue please mark the answer as correct, if not let me know!

 

Thanks!

Phil

Labels
Top Solution Authors