Alteryx Designer Desktop Discussions

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

Need help with contains or using findstring

AI
7 - Meteor

Hello,

 

I need to check a flag and if a name field does not contain either : Type, Code, Indicator then write out the records/error message. I am trying to use the following code in formula tool, but this doesn't seem to work for me.

 

If ([Flag] = 'Y' and (!Contains([Name], 'Type',1) || !Contains([Name], 'Indicator',1) || !Contains({Name], 'Code',1) || !Contains([Name], 'Party',1))) then 'Error - Attribute: '+ [Name]+ else '' endif

 

Is there a better approach to handling this and can I use FindString to do a similar check? If so, can someone help with some pointers?

 

Thanks in advance!

2 REPLIES 2
MarqueeCrew
20 - Arcturus
20 - Arcturus
IF
     [Flag] == 'Y' AND 
     (        !Contains([Name], 'Type') AND !Contains([Name], 'Indicator') AND
               !Contains([Name], 'Code')
     )
THEN 'Error - Attribute: ' + [Name]
ELSE ''
ENDIF

I think that this is what you are looking for.

 

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
AI
7 - Meteor

Hi Mark,

 

Thank you! I was getting a "Malformed If statement" message due to some extra parenthesis in the code you provided and I fixed it and it worked.

Labels