cancel
Showing results for
Search instead for
Did you mean:

# Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
###### Upgrade Alteryx Designer in 10 Steps

Debating whether or not to upgrade to the latest version of Alteryx Designer?

LEARN MORE
SOLVED

## Multi-Condition IF THEN ELSE statement

Asteroid

Hi All,

I was wondering if anyone knows of a way to do a multi-condition 'IF THEN ELSE' statement in the formula tool,

I want to replace the contents of a string but only if two conditions are met, so for example:

Output Field

[FIELD 1]

IF [FIELD 2] = "X" and [FIELD 3] = "Y" THEN "Replacement Text" ELSE [FIELD 1] ENDIF

Alternitivly is there a better way to acheive this?

Thanks in advance...

Magnetar

Your solution looks good to me.  I don't think you can simplify it further than that.

Asteroid

Hi John,

Thanks for the quick response - when I was typing it as I did in the example I was getting an error about an unrecognised variable "and" so assumed there had to be another way to do this.  After you pointed out this was the correct way to do it I retyped the formula and this time it worked - must have been a typo in there!

Thanks again.

Magnetar

Wild guess: a space in the "ENDIF" ... that one has gotten me often enough to be memorable.

Asteroid

Hah, quite possibly :smileytongue:

Nebula

I tend to prefer the IIF for simple statements as have made that mistake too often!

Asteroid
I've not used the IIF before, how does it differ from using IF THEN ELSE?
Magnetar

In a nutshell:

IF c THEN t ELSE f ENDIF

(is the same as)

IIF(c,t,f)

Nebula
It stands for inline if

IIF(<condition>,<true expression>,<false expression>)

Is a nice compact form.
Asteroid
Great, less typing, will definitely make use of this going forward - thanks both
Labels