Alteryx Designer Desktop Discussions

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

Passing variable in Control parameter

Balajiprasad
7 - Meteor

Is there a way to pass a variable (present in the input dataset) using control parameter (or by any other means) to a workflow? If yes, is it possible to get the parameter working throughout the entire workflow?

Example: I have a dataset with many amount variables (Amount1, Amount2, Amount3, etc). I need to pass one of these variables (let's  say Amount1) as input to a workflow. The workflow should do all the calculations based on this one variable. 

In the second case, I need to pass Amount2 and the workflow should do all the calculations using Amount2 now and so on.

 

Is there a way to accomplish this task? Thanks!

10 REPLIES 10
Thableaus
17 - Castor
17 - Castor

Hi @Balajiprasad 

 

Could you please post a sample of your data and clarify a little bit better what you're trying to do?

 

Like - defining what you want input, and what your output is gonna be.

 

Cheers,

Balajiprasad
7 - Meteor

My Input data will look like the below:

Amount1  Amount2 Amount3
123          456          789
012          345          678
901          234          567

 

Let's say I have a workflow (just an example) that just calculates the sum of each field. If I pass Amount1 to the workflow the result will be 1036. If I pass Amount2, result will be 1035 and same happens for Amount3.

Now I need to pass these field names dynamically. Based on the Input the workflow should produce the output.

Hope it is clear. If not please let me know. Thanks!

Thableaus
17 - Castor
17 - Castor

@Balajiprasad 

 

Do you wanna choose which field is going to be passed?

 

Or you want to generate a sum of these amounts each time the workflow runs?

 

There are two approaches in this situation:

 

1) If you want to make the choice - Analytic App is the best option.

 

2) If you want to generate a sum of each field for every iteration (everytime the workflow runs), and then union the results for each amount, then you could use a batch macro. 

 

Cheers,

Balajiprasad
7 - Meteor

Thanks @Thableaus 

I need to know how to input the variable name dynamically and also how to access it in different tools.

Thableaus
17 - Castor
17 - Castor

@Balajiprasad 

 

I'm not so sure if this is exactly what you're looking for..

 

But here is a way to pass your field as a parameter and modify tools.

 

Ex2.PNG

 

 

Ex1.PNG

 

The Macro itself is very simple. The control parameter will change the field being Summarized. So, anything you put in the Control Parameter will do that. To keep track of what is being Summarized, I also added a Text Input and Joined by Position, so I can say for example:

Amount 1 - got that sum of amount..

 

The workflow uses the Field Info tool to get the name of the Fields. So these names are passed in the Control Parameter, that way, every iteration that is run will change the Summarize tool, resulting in a different sum of amount depending on the field that was input.

 

Is that clear to you? Is this what you want?

 

Workflow with Macro appended

 

Cheers,

Balajiprasad
7 - Meteor

@Thableaus 

 

Yes this is what I want. Thanks for the quick solution.

 

Balajiprasad
7 - Meteor

@Thableaus 

 

I have one more question related to this. I am using a similar workflow with the only difference is I have two fields in Group By category in addition to the Sum calculation field.

 

Now if I pass my variable names through control parameters to change one of the Group By fields dynamically, I am getting an error stating "The field schema for the output "Output6" changed between iterations."

 

How to overcome this? Thanks!

AlanFan
5 - Atom

Since the behavior of batch macros is to union the macro outputs, the Macro Output schema must be the same every time.  By renaming the Output Field Name in the Summarize tool, you can dynamically choose which attribute to group by while maintaining a consistent Field Name.  If the data types are different (e.g. String vs Double, String(10) vs String(3)), you can pass a Select tool before the output to standardize it.

atamertarslan
8 - Asteroid

Hello @Thableaus,

 

Do you know a way to use a macro with two different inputs for the control parameter? In the end I want to feed the macro with two different inputs, which will then change some property of two elements at the same time with their different input.

 

In your example there is one input going into the macro with the control parameter, also updating two elements at the same time but with the same input.

 

Best,

Atamert

Labels