community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Multiple commands in If-Then-statement

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?

Highlighted
Alteryx
Alteryx

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.

Alteryx Certified Partner
Alteryx Certified Partner

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,

Alteryx Certified Partner
Alteryx Certified Partner

@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,

Alteryx
Alteryx

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

This was it, thank you for your help!!

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. 

@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