Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Formula with Multiple Conditions

Learner09
8 - Asteroid

Hello All,

 

I am trying to add new logic to the existing Alteryx workflow formulae. Could anyone please assist in how I add new logic?

 

Existing Formula 

 

IF IsEmpty([Line type])
THENIF Contains([Order Type], "BILL") THEN "BILL"
ELSE "NEW" ENDIF ELSE [Line type] ENDIF

 

I am trying to add new categories in THENIF Contains([Line Type] like Internal, Trial, Return

 

Example - IF IsEmpty([Line type])
THENIF Contains([Order Type], "BILL") THEN "BILL" OR Contains([Order Type], "Return") THEN "Return"
ELSE "NEW" ENDIF ELSE [line type] ENDIF

 

Thanks,

 

 

 

4 REPLIES 4
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Learner09,

 

You'll want to use an AND condition for where you have multiple conditions. The IF statement works in three main steps
(1) IF - Initial condition to test for

(2) THEN - What happens if that is true?

(3) OPTIONAL ELSEIF - If you have further conditions to test for

(4) OPTIONAL THEN - If you are testing for further conditions in step (3) you return this result

(5) ELSE - If none of the above is true return this result

(6) END - Finish IF statement

 

You example in this case would look something like the below:

 

IF (IsEmpty([Line type]) AND Contains([Order Type], "BILL")) THEN "BILL" ELSEIF Contains([Order Type], "Return") THEN "Return"
ELSE "NEW" ENDIF

 

Kind regards,

Jonathan

Christina_H
14 - Magnetar

Based on what I think your formula is doing, I would turn it around to get the non-empty Line type out of the way first.  Then just add as many ELSEIF clauses as you need, e.g.

IF !IsEmpty([Line type]) THEN [Line type]
ELSEIF Contains([Order Type], "BILL") THEN "BILL"

ELSEIF Contains([Order Type], "Return") THEN "Return"
ELSE "NEW" ENDIF

Learner09
8 - Asteroid

Thank you @Jonathan-Sherman 

Jonathan-Sherman
15 - Aurora
15 - Aurora

No problem at all @Learner09!

Labels