Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Use of parameters in formula's

jvanderpol
7 - Meteor

I am a relative newbie to Alteryx,but could not find an answer to below without the use of constants

 

IF a THEN [example] = 10 * [example] 

 

ELSEIF b THEN [example] = 20 * [example] 

 

ELSE [example] = 30 * [example]

 

ENDIF

 

How can I input the parameters (10, 20 and 30 in the example above), without

a) using constants (therefore I have too many parameters in my model, unless I could input/ import constants from an external excel source...

b) creating 3 extra columns all filled with the same number 10, 20 and 30

 

Thanks.

6 REPLIES 6
DataNath
17 - Castor
17 - Castor

The Interface tools are definitely a go-to when you need to pass in user-defined (parameter) values. As a result, you'll have to turn this into an app or macro, but here's a quick example:

 

You set up the workflow as normal, with just some dummy values, as these will be replaced by the user selection anyway. Here I've just used 10 like in your example - 

 

DataNath_0-1657268937549.png

 

 

Then you set up your Action tool to update only this part of the expression (in this case the 10) - 

 

DataNath_1-1657268967789.png

 

Now when I run this, it'll replace the 10 with whatever number I provide and show the outcome - 

 

DataNath_2-1657269005237.png

 

I just used a numeric up/down as it seems the most suitable for your use, but in reality there's a bunch of tools under the 'Interface' palette. In your case you'd just need to do this 3 times - one for each value in your if statement.

 

Hope this helps - have attached my workflow for reference.

jvanderpol
7 - Meteor

Thank you DataNath,

 

See how this could work, but not sure I want (as only user) to input ca 15 parameters every time I run this. Have now an excel with different parameters for different countries.

 

 

DataNath
17 - Castor
17 - Castor

@jvanderpol so you have values in a main table and if they match values from a second table you want to use the multiplier associated with that? If so, you can do this fairly easily with a mapping table and the find & replace function. If you can provide some dummy data/a workflow you have in progress that'd be great.

jvanderpol
7 - Meteor

like the "fairly easily" in your reply. However, have not clue what you mean with the find replace (apologies for being a newbie :))

jvanderpol_0-1657274047460.png

 

DataNath
17 - Castor
17 - Castor

No problem @jvanderpol! So here, I basically made a little look-up table with the types and what multiplier you want to apply to each (just used random values, obviously change these to fit your use):

 

DataNath_0-1657274653377.png

 

In the Find & Replace, we can then use this tool to look for a match in Types in your main dataset. Where it finds a match, it then appends the relevant multiplier:

 

DataNath_1-1657274714824.png

 

Then, in your formula tool, you can simply reference the multiplier field, rather than having to type out the values yourself - again, I just added this to your current formula to demonstrate but you'll need to change this as needed for your use:

 

DataNath_2-1657274772555.png

 

Workbook attached, let me know if there's any issues!

jvanderpol
7 - Meteor

Thanks, works indeed. Would have hoped for a solution without the step of adding an additional column, but does the job nicely.

 

Appreciate your help in this #neverstoplearning

Labels
Top Solution Authors