# Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
The Expert Exam is now live online! Read about the specifics and what it took to bring it to life in the blog by our very own Elizabeth Bonnell!
SOLVED

## Multi-Condition IF THEN ELSE statement

Highlighted
8 - 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?

Highlighted
15 - Aurora

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

Highlighted
8 - 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.

Highlighted
15 - Aurora

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

Highlighted
8 - Asteroid

Hah, quite possibly

Highlighted
16 - Nebula

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

Highlighted
8 - Asteroid
I've not used the IIF before, how does it differ from using IF THEN ELSE?
Highlighted
15 - Aurora

In a nutshell:

IF c THEN t ELSE f ENDIF

(is the same as)

IIF(c,t,f)

Highlighted
16 - Nebula
It stands for inline if

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

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