Alteryx Designer Desktop Discussions

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

Nested If then statement

crtakacs
8 - Asteroid

How should this nested if then statement be formed? I'm getting a malformed if statement error. 

 

I'm trying to identify If [PURITY_PROD_CD] = "CRD"

 

If it is not "CRD" then [Correct Risk Open Volume]=[SIGN_PRICED_VOL]

 

If it is "CRD" then

 

if [PRICE] != 0

 

then 

 

[Correct Risk Open Volume]=[SIGN_PRICED_VOL]

 

else

 

[Correct Risk Open Volume]=0

 

crtakacs_0-1598478032447.png

 

 

 

3 REPLIES 3
markcurry
12 - Quasar

Is this what you are looking for...

 

If [PURITY_PROD_CD] = "CRD" THEN
   IF [PRICE] != 0 THEN
       [SIGNED_PRICE_VOLD]
  ELSE
      0
   ENDIF
ELSE
     [SIGNED_PRICE_VOLD]
ENDIF

 

You don't need to include the new field name, when updating the values, so just have [SIGN_PRICED_VOL] instead of [Correct Risk Open Volume]= [SIGN_PRICED_VOL]

 

I hope that helps.

 

 

 

 

T_Willins
14 - Magnetar
14 - Magnetar

Hi @crtakacs,

 

The format for Alteryx is IF...THEN...ELSEIF...THEN... ELSE... ENDIF   Your syntax and order need to be shifted around.

 

Try:  

 

IF [PURITY_PROD_CD] != "CRD" THEN [Correct Risk Open Volume] = [SIGN_PRICED_VOL] ELSEIF [PRICE] != 0 THEN  [Correct Risk Open Volume]=[SIGN_PRICED_VOL] ELSE [Correct Risk Open Volume]=0 ENDIF

 

This looks first for not equal to CRD for the first if, then looks at price to split the remainder.

 

 

 

else

 

[Correct Risk Open Volume]=0

crtakacs
8 - Asteroid

Worked perfect - thanks! 

Labels