ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests Early 2026. Make sure to check your account preferences in my.alteryx.com to make sure you have filled out your security questions. Learn more here
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
GELÖST

Malformed if Statement

SACResearch
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 ANTWORTEN 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
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
Meteoroid

Thank you for your assistance!

bayo
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
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
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
Beschriftungen
Top-Lösungs-Autoren