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

IF Contain error

Amy123
8 - Asteroid

Hi ,

 

Can anyone help me how to write the below logic in alteryx i am new to it.

 

IF Contain [Journal Category] , "M","MA","MR"  then [Journal Description] Else [Transaction Code] Endif

 

I am getting this error.

 

Amy123_0-1624024136457.png

 

5 REPLIES 5
Emil_Kos
17 - Castor
17 - Castor

Hi @Amy123,

 

IF [Jorunay Category] In ("A","B","C") would should you only positions equal to A or B and C. 

 

If you want to use contains function for several arguments I would use the find and replace tool as it would be easier to maintain in a long run. Unless if you have a big data set. 


If you have big data set you can write IF 1 st contain function OR 2 nd contain function OR 3 rd contain function etc. 

HomesickSurfer
12 - Quasar

Try:  IF Contains([Journal Category], "M") OR Contains([Journal Category], "MA") OR Contains([Journal Category], "MR") THEN [Journal Description] ELSE [Transaction Code] ENDIF

HomesickSurfer
12 - Quasar

Hi @Amy123 

 

If my chance that your Journal Category that you attempt to isolate the description for each start with 'M', try:

 

IF StartsWith[Journal Category], "M") THEN [Journal Description] ELSE [Transaction Code] ENDIF

MarqueeCrew
20 - Arcturus
20 - Arcturus

@HomesickSurfer ,@Amy123 ,@Emil_Kos ,

 

I want to point out that M, MA and MR all contain "M".

 

If you are really looking for M, MA, MR as the "Whole Value", then use an in clause 

IIF([Journal Category] in ('M', 'MA', 'MR'), [Journal Category], [Transaction Code])

otherwise, 

IIF(Contains([Journal Category],"M"), [Journal Category], [Transaction Code])

 

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
HomesickSurfer
12 - Quasar

Hi @MarqueeCrew 

 

I like both of your formula expressions.  I trust that the below 'StartsWith' can work if the values begin with 'M' as 'Contains' will also include 'AM, PM, FM, Mickey Mouse, etc..'

 

IIF(StartsWith([Journal Category],"M"), [Journal Category], [Transaction Code])

 

Labels