Advent of Code is now back for a limited time only! Complete as many challenges as you can to earn those badges you may have missed in December. Learn more about how to participate here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

If & elseif & correct end? formula question...

MaryCann
8 - Asteroid

ARGH!  😖 (ooh, we have emoji's here!) Okay, in the snip below, at first the 5 doesn't work.  In the second portion the end doesn't work!  😕 I figure I'm missing something here, but my newby self doesn't know what it is.  What do ya'all recommend?

MaryCann_0-1661438345079.png

Thank you in advance.  😁

3 REPLIES 3
DataNath
17 - Castor
17 - Castor

@MaryCann I'd check that your [Assessment Type] field is Numeric - if it's still a string then you'll either need to change it to numeric for this to work, or wrap all of the digits in your expression in quotes to make sure Alteryx is looking for strings i.e. [Assessment Type] = "2"

 

If you do make [Assessment Type] numeric, then you'll need to use else ToString[Assessment Type] endif to finish off your statement, otherwise you'll be trying to output a number into a string field.

 

For the second statement, you'll need to do the same checks and in Alteryx you end expressions with ENDIF (I'm fairly sure you're a Tableau user so are likely used to just using END there)!

 

*You'll also need to give your second expression a name - it'll currently error even if you make the above adjustments, as you haven't given it one.

MaryCann
8 - Asteroid

@DataNath  - that's it!  It was a string field. 😊  OMG!  And, you are absolutely correct, I do use Tableau as well.

 

Thank you DataNath!  🎉

ChrisTX
16 - Nebula
16 - Nebula

I don't see any issues with the first formula.  Maybe close Alteryx and re-open?

 

The correct end statement is definitely "ENDIF"

 

See the function list for syntax: https://help.alteryx.com/20221/designer/functions

 

For the final ELSE, I think the formula should auto-convert [Assessment Type] from a number to a string, so that shouldn't be a problem.

 

Take a look at the SWITCH function.

 

Switch(Value,Default,Case1,Result1,...,CaseN,ResultN): Compares a value against a list of cases and returns the corresponding result.

Switch([Class], Null(), "Gold",1,"Silver",2,"Bronze", 3,"Tin", 4, "Aluminum",5)

 

Tip: line breaks in a formula are allowed, and can make a formula easier to read

 

Chris

Labels
Top Solution Authors