In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. Set up your security questions now so you can recover your account anytime, just log out and back in to get started. Learn more 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