Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Nested If-Else condition not working

madhurinani
8 - Asteroid

I have used the below logic for nested if else condition.

I want to create a logic which says that if none of the conditions match the criteria, it should show as "marginal"

 

IF [Change]=0 THEN "No change"
ELSEIF [PQ FD %]>15 and [Current FD Own %]<15 then "Change below 15%"
ELSEIF [PQ FD %]>20 and [Current FD Own %]<20 then "Change below 20%"
ELSEIF [PQ FD %]>25 and [Current FD Own %]<25 then "Change below 25%"
ELSEIF [PQ FD %]>50 and [Current FD Own %]<50 then "Change below 50%"
ELSEIF [PQ FD %]<15 and [Current FD Own %]>15 then "Change above 15%"
ELSEIF [PQ FD %]<20 and [Current FD Own %]>20 then "Change above 20%"
ELSEIF [PQ FD %]<25 and [Current FD Own %]>25 then "Change above 25%"
ELSEIF [PQ FD %]<50 and [Current FD Own %]>50 then "Change above 50%"
ELSEIF [PQ FD %]=0 and [Current FD Own %]>0 then "New Investment"
ELSEIF [PQ FD %]>0 and [Current FD Own %]="" then "Liquidation"
else "marginal"
ENDIF

 

But somehow It is not working properly. As the highlighted Category column show ideally display as "marginal"

Any help would be amazing.

 

Thanks!

3 REPLIES 3
DataNath
17 - Castor
17 - Castor

Hey @madhurinani, what are you checking for in this last line?

 

ELSEIF [PQ FD %]>0 and [Current FD Own %]="" then "Liquidation"

 

Where you have ="", Alteryx is checking for a blank string value because of the quotation marks, whereas all of your other conditions are based on numeric checks. Are you looking for a blank/null here? If so, you could perhaps try using AND isempty([Current FD Own %]) or AND isnull([Current FD Own %]).

IraWatt
17 - Castor
17 - Castor

Hey @madhurinani,

Like @DataNath found all you need to do is change this check to something like NULL(). You cant compare a number to text.

IraWatt_0-1656930442743.png

IF [Change]=0 THEN "No change"
ELSEIF [PQ FD %]>15 and [Current FD Own %]<15 then "Change below 15%"
ELSEIF [PQ FD %]>20 and [Current FD Own %]<20 then "Change below 20%"
ELSEIF [PQ FD %]>25 and [Current FD Own %]<25 then "Change below 25%"
ELSEIF [PQ FD %]>50 and [Current FD Own %]<50 then "Change below 50%"
ELSEIF [PQ FD %]<15 and [Current FD Own %]>15 then "Change above 15%"
ELSEIF [PQ FD %]<20 and [Current FD Own %]>20 then "Change above 20%"
ELSEIF [PQ FD %]<25 and [Current FD Own %]>25 then "Change above 25%"
ELSEIF [PQ FD %]<50 and [Current FD Own %]>50 then "Change above 50%"
ELSEIF [PQ FD %]=0 and [Current FD Own %]>0 then "New Investment"
ELSEIF [PQ FD %]>0 and [Current FD Own %]=NULL() then "Liquidation"
else "No Change"
ENDIF

 

madhurinani
8 - Asteroid

Thank you both. 
Understood on the mistake on my last ELSEIF condition, the code wasn't reaching the last part of the ELSE condition due to that.
I have fixed that.

Thank you both for your help.

 

 

Labels
Top Solution Authors