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

Alteryx Designer Desktop Discussions

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

Malformed if Statement

SACResearch
6 - Meteoroid

I am trying to do the following formula, but continue to get a malformed if error. Can someone tell me what I'm doing wrong?

 

IF [CUM_HSGPA_Calculated_From_Courses_Unweighted] <="2.00" THEN '0.00 to 2.00' ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>"2.00" AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<="2.50" THEN '2.01 to 2.50' ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>"2.50" AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<="3.00" THEN '2.51 to 3.00' ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>"3.00" AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<="3.50" THEN '3.01 to 3.50' ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>"3.50" AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<="4.00" THEN '3.51 to 4.00'
ENDIF

12 REPLIES 12
michael_treadwell
ACE Emeritus
ACE Emeritus

Couple of things here

 

First, you don't have a final ELSE statement which is causing an issue.

 

Also, you can't use < and > with "strings"

 

Remove the quotes around your values when using < or >. Those values must be numeric.

SACResearch
6 - Meteoroid

I have changed it to the following:

 

IF [CUM_HSGPA_Calculated_From_Courses_Unweighted] <=2.00 THEN 0.00 to 2.00 ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>2.00 AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<=2.50 THEN 2.01 to 2.50 ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>2.50 AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<=3.00 THEN 2.51 to 3.00 ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>3.00 AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<=3.50 THEN 3.01 to 3.50 ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>3.50 AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<=4.00 THEN 3.51 to 4.00 ELSEIF Null()
ENDIF

 

Still shows as an error.

MarqueeCrew
20 - Arcturus
20 - Arcturus
IF [CUM_HSGPA_Calculated_From_Courses_Unweighted] <=2.00 THEN '0.00 to 2.00' ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>2.00 AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<=2.50 THEN '2.01 to 2.50' ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>2.50 AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<=3.00 THEN '2.51 to 3.00' ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>3.00 AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<=3.50 THEN '3.01 to 3.50' ELSEIF
[CUM_HSGPA_Calculated_From_Courses_Unweighted]>3.50 AND [CUM_HSGPA_Calculated_From_Courses_Unweighted]<=4.00 THEN '3.51 to 4.00' ELSE
'ERROR'
ENDIF

This is the interpretation that will work.  I didn't test for NULL, it will catch null in the ELSE.

 

Note:  This results in a STRING.  Make sure that your field is defined as a vstring.

 

Thanks,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
michael_treadwell
ACE Emeritus
ACE Emeritus

IF ELSEIF ELSEIF .... ELSEIF ELSE ENDIF is the pattern

 

You must have a final ELSE before the ENDIF

SACResearch
6 - Meteoroid

Thank you for your assistance!

bayo
5 - Atom

I am having difficulty with this. Invalid type in operator <. Can some one help?

 

IF ([New WOS after Flush]>[Std+1]) THEN 8000 ELSEIF ([New WOS after Flush]<[Std-1]) THEN 9000 ELSE 5000 ENDIF

 

or

 

IF ([New WOS after Flush]>[Std+1]) THEN "Tier3" ELSEIF ([New WOS after Flush]<[Std-1]) THEN "Tier1" ELSE "Tier2" ENDIF

JohnJPS
15 - Aurora

Hi @bayo

Please ensure that the field [New WOS after Flush] and [Std] are both numeric types.  The message suggests to me that one or the other isn't.

Hope that helps!

John

bayo
5 - Atom

@JohnJPS

 

Yes my error. Thank you

NicoleJohnson
ACE Emeritus
ACE Emeritus
You can remove the extra IF after each ELSEIF, that should do it! :)

NJ
Labels
Top Solution Authors