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

Alteryx designer Discussions

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

Dynamic conditional formula?

Meteoroid

I'm building a decision tree tool using multiple conditions / criteria : 

 

Decision Output - Should we offer 30% promotion discount to a group(s)?

 

Here's how I envision it to be : 

 

Customer GroupRule 1Rule 2 Rule 3Rule 4OUTPUT
USATRUEFALSETRUETRUEDiscount
FranceTRUETRUEFALSEFALSENo Discount
GermanyFALSETRUETRUE Discount

 

Each rule represents a specific, formula driven test results 

 

For US - We will provide a discount if Both Rule 1 + Rule 2 are TRUE or if both RULE 3 and 4 are true.

For France  - We will provide a discount if Rule 1 + 2 + 3 are true or if Rule 4 is true

For Germany - We will provide a discount if either one of the Rule 1 or Rule 2 or Rule 3 is true. 

 

I can create a unique formula for each region, but I have 42 other countries and was wondering if we can develop a formula that is dynamic and can be used for all of the countries. To do so, I thought it would be helpful to change the table to like this:

Customer GroupRule 1link1Rule 2 link2Rule 3link3Rule 4
USATRUEANDFALSE;TRUEANDTRUE
FranceTRUEANDTRUEANDFALSE;FALSE
GermanyFALSEORTRUEORTRUE

 

But I'm still having trouble coming up with a formula using the data structure above. Can you help? 

Alteryx Certified Partner

@swoo008,

 

Use the below expression in the formula tool to get new field as "Discount" or "No Discount" :

 

if [Customer Group]="USA" and ([Rule 1]="TRUE" and [Rule 2 ]="TRUE") then "Discount" elseif
[Customer Group]="USA" and ( [Rule 3]="TRUE" and [Rule 4]="TRUE") then "Discount" elseif
[Customer Group]="France" and ([Rule 1]="TRUE" and [Rule 2 ]="TRUE" and [Rule 3]="TRUE") then "Discount"
elseif [Customer Group]="France" and [Rule 4]="TRUE" then "Discount" elseif
[Customer Group]="Germany" and ([Rule 1]="TRUE" or [Rule 2 ]="TRUE" or [Rule 3]="TRUE") then "Discount" else "No Discount" endif

 

Thanks,

Vishwa

Bolide

Hi @swoo008

 

I would suggest using the CReW dynamic formula macro written by @AdamR:

http://help.chaosreignswithin.com/DynamicFormula.html

 

I would also split the OR formula to separate lines and keep the AND ones one the same line:

 

Capture1.PNG

Labels