Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Alteryx is here to help you solve your biggest data challenges. Read about the new Virtual Solution Center here.
SOLVED

If Then Statement vs Inline If Statement

Highlighted
8 - Asteroid

Can someone articulate the difference between the If Then Statement and the Inline If Statement?  I understand how to write each, but I am trying to understand why both are needed because they seem to be identical in function but just offer two options based on user preference.  I am sure it depends on who you ask as to what a person prefers, but I'm curious if there is an instance where one would actually perform a function where the other would not.  Thank you!

Highlighted
14 - Magnetar
14 - Magnetar

Hi @djodts 

 

For me, it depends on the complexity of the statement. If there are multiple OR or AND clauses involved, then I'm inclined to use the IF/THEN/ELSE over the IIF.

If it's a simpler case of checking a condition for true or false, then I go with the IIF. Easier for me in terms of fewer pieces to remember (and being a Tableau user, having to remember to use ENDIF and not simply END).

 

If there are many simple conditions to test, I actually prefer SWITCH to either IIF or IF/THEN/ELSE.

 

Hope that offers some insight!!

 

Cheers,

Esther

Highlighted
8 - Asteroid

Thank you for your insight!

5 - Atom

Something to keep in mind with in-line IF statements … in some languages IIF() always evaluates both true part and false part, even though it returns only one of them possibly leading to undesirable side effects and slower execution  whereas the IF...THEN...ELSE construct, while textually longer, only evaluates the true/false parts at runtime based upon the flow of logic.

 

For simple Boolean logic with a smaller number of records it may be a non-issue.  For complicated logic there could be unintended consequences and for large number of records the incremental increase in execution time on each record may add up.

Labels