Free Trial

Alteryx Designer Desktop Discussions

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

if statements, startswith, AND function in one expression

krishnagandhi
8 - Asteroid

Hi,

I have some data that i am trying to categorize and i am writing a formula, but it is just not working (it is all string data). Here is the formula:

if [Service Category] = "LABO" then "Labour"
Elseif [service category] = "LSUM" and StartsWith("EDIT,", [Service Short Text]) then "Edit"
else "0"
Endif

krishnagandhi_1-1586894897692.png

 

As you can see the very final cell should read Edit but for some reason i can't get the formula to work. Am I writing something incorrect or is this not possible to write in Alteryx.

 

Thanks,

 

Krishna

2 REPLIES 2
ChrisTX
16 - Nebula
16 - Nebula

I think your StartsWith code is wrong

 

StartsWith('ABC123', 'ABC') returns TRUE

 

StartsWith(String, Target, CaseInsensitive=1): Checks if a string starts with a particular string. Returns a TRUE or FALSE if the string matches the pattern. It is defaulted to case insensitive.

 

The Alteryx documentation use of "target" is confusing.

 

Here's a list of all functions:

https://help.alteryx.com/current/Reference/Functions.htm

 

 

krishnagandhi
8 - Asteroid

Thanks that guide was really helpful, i amended the formula to use a Left statement and it works now!

 

if [Service Category] = "LABO" then "Labour"
Elseif [service category] = "LSUM" and Left([Service Short Text], 4) ="EDIT" then "Edit"
else "0"
endif

Labels
Top Solution Authors