if statements, startswith, AND function in one expression
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
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
Solved! Go to Solution.
- Labels:
- Datasets
- Expression
- Tips and Tricks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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