In case you missed the announcement: The Alteryx One Fall Release is here! Learn more about the new features and capabilities here
ACT NOW: The Alteryx team will be retiring support for Community account recovery and Community email-change requests after December 31, 2025. 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.
SOLVED

IF Statement Struggles

katherinetdavita
8 - Asteroid

I don't know why but I struggle getting if statements right! Image of what I'm trying to get to:

TAble.PNG

 

And my formula tool. I can't figure out what the heck I've done wrong

 

Formula.PNG

10 REPLIES 10
alexnajm
19 - Altair
19 - Altair

Try to make them ELSEIF instead of Ese If - aka no space!

alexnajm
19 - Altair
19 - Altair

Also make sure there's a space before your ENDIF

katherinetdavita
8 - Asteroid

Thanks, I think that was part of my problem but i'm still getting the error after correcting those.... something to do with the ENDIF at the end?

form2.PNG

alexnajm
19 - Altair
19 - Altair

Yes, I am assuming it goes to the second comment - make sure there's a space before your ENDIF

DataNath
17 - Castor
17 - Castor

@katherinetdavita the persisting issue is that you don't have an ELSE anywhere.

 

ELSEIFs are used to provide multiple alternative outcomes. However, you always need a final 'ELSE' which is basically saying: if none of the above checks are satisfied, then do this. This comes right at the end, before your ENDIF. So your statement would be structured like so:

 

IF a = b THEN w

ELSEIF a = c THEN x

ELSEIF a = d THEN y

ELSE z

END

 

As a side tip, you can clean up your statement a little here. Instead of using [Field] = Null() or Field != Null(), you can use the IsNull() function which checks whether the field you place inside is null. ! makes it NOT just the same so you'd use IsNull([Field]) and !IsNull([Field]).

alexnajm
19 - Altair
19 - Altair

Yes @DataNath ^

katherinetdavita
8 - Asteroid

@alexnajm and @DataNath using both of your help, the error has now cleared so I think I've got the formula right:

form 3.PNG

But the output is not working right to use the Completion date for the output as intended:

Capture2.PNG

alexnajm
19 - Altair
19 - Altair

You are evaluating if the column is null or not, but "-" is not a null value - I would likely type something like ... [Exp Grad Date from Prog Rpt]="-" AND [Completion Date from Prog Rpt]="-" ...

katherinetdavita
8 - Asteroid

Ah! Thank you! I thought those "-" were nulls. Here's what finally did it:

Capture3.PNG

Labels
Top Solution Authors