Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Multiple commands in If-Then-statement

Michaelovermyer
7 - Meteor

Hello, 

 

Is it possible to to include two different sets of commands in an IF THEN ELSE statement? E.G. 

 

IF [Category Description] = 'STIF' AND [Term] = 'Long Term' THEN

[Category Description] = 'Short Term' Else 0 ENDIF

 

Basically I need the formula to Check the Category Description field to see if it contains 'STIF', if Category Description does contain 'STIF' then check the Term field to see if it is 'Long Term', and if both of these are true then the Term field changes those that contain 'STIF' in Category Description and 'Long-Term' in Field to 'Short -Term' and the rest stay the same. Is this possible? Would the Multi Field Formula be able to do this?

7 REPLIES 7
BenBo
Alteryx Alumni (Retired)

You have the logic correct by including the AND statement in your IF clause. I like to wrap things in parentheses as it makes reading it a bit easier. For example:

 

if ([Category]="STIF" AND [Term]="Long Term")
then "Short Term"
else [Category]
endif

 

In this example, I'm simply updating the existing column named Category. I've attached a very simple workflow that may help.

Thableaus
17 - Castor
17 - Castor

Hi @Michaelovermyer 

 

This is what you're looking for:

 

Basically I need the formula to Check the Category Description field to see if it contains 'STIF', if Category Description does contain 'STIF' then check the Term field to see if it is 'Long Term', and if both of these are true then the Term field changes those that contain 'STIF' in Category Description and 'Long-Term' in Field to 'Short -Term' and the rest stay the same. Is this possible? Would the Multi Field Formula be able to do this?

 

 

Field in Formula Tool: Term

IF Contains([Category Description], 'STIF') AND [Term] = "Long Term" THEN

"Short Term" ELSE [Term] ENDIF

 

Cheers,

Thableaus
17 - Castor
17 - Castor

@BenBo 

 

I might be wrong then, because in my understanding the field "Term" is the one changing.

 

But @Michaelovermyer  could clear it up for us.

 

Cheers,

BenBo
Alteryx Alumni (Retired)

@Thableaus ah, you may be correct. Either way, our logic seems to be similar and hopefully helps!

Michaelovermyer
7 - Meteor

This was it, thank you for your help!!

Michaelovermyer
7 - Meteor

Thank you for this! I was able to get it to work going off of the above post but this is what it ended up essentially being. 

Michaelovermyer
7 - Meteor

@BenBo and @Thableaus I was able to discern the solution from @BenBos post but the solution posted by @Thableaus was essentially the exact syntax I ended up using

Labels