Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
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
18 - Pollux
18 - Pollux

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

alexnajm
18 - Pollux
18 - Pollux

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
18 - Pollux
18 - Pollux

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
18 - Pollux
18 - Pollux

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
18 - Pollux
18 - Pollux

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