Alteryx Designer Desktop Discussions

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

Contains and Startswith not working?

Bobbins
8 - Asteroid

Simple text:

Field1Result
Slate1
SLATE1
SLATE:1
SLATE: THIS IS ANOTHER TEST0
SLATE V20
SLATE V30


Formula:

 

IF 
Startswith("SLATE:",[Field1]) then 1 elseIF 
Contains("SLATE",[Field1]) then 2 else
0 endif

 

Why are the bottom 3 rows still giving 0 for? 

Thank you. Packed workbook included

 

 

3 REPLIES 3
JosephSerpis
17 - Castor
17 - Castor

Hi @Bobbins you need to swap the arguements in your contains statement for it to work.

 

IF 

StartsWith("SLATE:",[Field1]) then 1 elseIF 
Contains([Field1],"SLATE") then 2 else


0 endif
MarqueeCrew
20 - Arcturus
20 - Arcturus

@Bobbins ,

 

So many varieties in your potential data, wouldn't you like to use a single function (set)?

 

UPPERCASE(GetWord([Text], 0))

 

Now you have a standardized view of the first word.

 

Here's a way to do this that is unique and (hopefully) easy to understand:

 

Switch(UPPERCASE(GetWord([Text], 0)),0,"SLATE:",1,"SLATE",2)

 

The default is 0

When it is SLATE you get 1

When it is SLATE: you get 2

 

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Bobbins
8 - Asteroid

@JosephSerpis I could have sworn i tried it the other way and it didnt work. Sorry. stupid error

@MarqueeCrew I am actually using case to define what words I do and don't need in this instance. I had not realized  "switch" was available to altreyx so thank you for the lesson!

Labels