Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

If statement for AND multiple conditions not working

cbabel14
6 - Meteoroid

I am having some issues with part of my coding as I want to fill up the blanks in city column with reference to other columns values in such a way that if city column will be filled up by State[value] else Country[value] or if none of the columns have any value or string it will be filled with "1".

 

the only portion that is not working is the condition where none of the columns have any value or string. it will be indicated as "1" in firm city

 

would greatly appreciate for some guidance

 

cbabel14_1-1617789428875.png 

cbabel14_2-1617789453226.png

cbabel14_3-1617789541343.png

 

 

Code:

if
IsEmpty([city])
then [state]
elseif
IsEmpty([city])&&IsEmpty([state])&&IsEmpty([country])
then "1"
elseif
IsEmpty([city])&&IsEmpty([state])
then [country]

else [city]
endif

2 REPLIES 2
Emil_Kos
17 - Castor
17 - Castor

Hi @cbabel14,

 

It will not work as it is checking the first condition and it is met. So it is skipping all of the rest conditions and it will not check if they are true. To make it work you need to swap conditions around

 

if
IsEmpty([city])&&IsEmpty([state])&&IsEmpty([country])
then "1"
elseif
IsEmpty([city])&&IsEmpty([state])
then [country]
elseif
IsEmpty([city])
then [state]

else [city]
endif

 

If I understand the request correctly it should start working for you!

cbabel14
6 - Meteoroid

Hey Emil

 

Alright! it works. That's certainly a very crucial part to take note of! Thanks!

Labels