alteryx Community

# Alteryx Designer Desktop Discussions

SOLVED

## Replace long nested If with simple formula

6 - Meteoroid

Hi Team,

I've to create a new column using the existing data with below condition.

If column A contains B,C,D and E then Column F should be Z

if column A contains H,I,J and K then Column F should be Y

 A F B Z C Z D Z E Z G Y H Y I Y J Y

Similar multiple condition are there.  I can use nested if, but that will be a long formula. Is there any simplified way/formula for this.

6 REPLIES 6
15 - Aurora

Hi @RK13,

Tough little question! I've managed to do it dynamically with the help of a lookup table of the values you want to check for.

Kind regards,

Jonathan

15 - Aurora

I've also assumed the field (column A) should contain all of B,C,D, E to produce Z as the outcome? If not just let me know!

6 - Meteoroid

Looks like question was bit confusing, I just updated my doubt with more details. [Added same below]

I've to create a new column using the existing data with below condition.

If column A contains B,C,D and E then Column F should be Z

if column A contains H,I,J and K then Column F should be Y

 A F B Z C Z D Z E Z G Y H Y I Y J Y

Similar multiple condition are there.  I can use nested if, but that will be a long formula. Is there any simplified way/formula for this.

13 - Pulsar

Hi @RK13

Is this what you are looking for? Created two examples (F1 and F2), see below:

F1 Formula:

if [A] IN ('B','C','D','E') THEN 'Z' ELSEIF
[A] IN ('H','I','J','K') THEN 'Y' ELSE Null() ENDIF

F2 Formula:

if [A] IN ('B','C','D','E') THEN 'Z' ELSE 'Y' ENDIF

6 - Meteoroid

This one works, thanks 🙂

15 - Aurora

Looks like I got the wrong end on this one! I thought it should contain all of A,B,C,D and E to get the outcome of Z. Nice work @pedrodrfaria using the IN() function!

Labels