Survey banner
The Dataiku Community is moving to a new home! Some short term disruption starting next week: LEARN MORE

IF contains multiple conditions

Solved!
yesitsmeoffical
Level 3
IF contains multiple conditions
col
A
B
3
10
if(contains(toUppercase(col),"A"),"letters",
if(contains(toUppercase(col),"B"),"letters",
"others"))

 

The code above works but is it possible to shorten it to combine the logic for "A" and "B"?

For example in the syntax below (albeit incorrect): 

if(contains(toUppercase(col),"A" or "B"),"letters",
"others")

 

0 Kudos
1 Solution
Turribeach

It's possible but not going to help you simplify the expression. Using the boolean operators:

if(contains(toUppercase("ABC"),"D") || contains(toUppercase("ABC"),"A"), "letters", "others")

Or using boolean functions:

if(or(contains(toUppercase("ABC"),"D"), contains(toUppercase("ABC"),"A")), "letters", "others")

You will be better using match() with a regular expression and check the output with length()

 

 

 

View solution in original post

1 Reply
Turribeach

It's possible but not going to help you simplify the expression. Using the boolean operators:

if(contains(toUppercase("ABC"),"D") || contains(toUppercase("ABC"),"A"), "letters", "others")

Or using boolean functions:

if(or(contains(toUppercase("ABC"),"D"), contains(toUppercase("ABC"),"A")), "letters", "others")

You will be better using match() with a regular expression and check the output with length()