Alteryx Designer Desktop Discussions

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

Control variables in a standard macro

jhe1
6 - Meteoroid

Dear Community, 

 

is there a way to implement a function and then feed different variables to the function? I implemented simple macro (standard, iterative and batch) before, yet I can't figure out the following workflow.

 

The two chunk workflows are the same, except each is based on individual column. The green comments aim to showcase how the corresponding tool is related to this column. The same calculation applies to column B, C, D etc.  It is possible to implement sth such as in Python:

  1. Define a function for the chunk workflow ---> Marco?
  2. Create a list/nparray to store the column names  ---> Control parameter?
  3. Call the function and pass each column name to the argument
  4. Output results

I've tried with batch macro and use the column names as control parameters. Yet no success. Pain points: The first Summarize Tool calculates the median based on this column. Then the median value is used for further calculation. Also for the Multi-Field Binning Tool, even connected with a Control Parameter. Still one error message: at least one field must be selected. 

 

jhe1_0-1671581956490.png

 

I'm afraid that I can't upload the dataset due to privacy. If my explanation is not enough, I'll see if I could mock a dataset. Otherwise, I appreciate your insight! Many thanks!

 

4 REPLIES 4
KSowers
Alteryx
Alteryx

Can you give an example of what a function would be and how you would want to change the variables within that function?

Felipe_Ribeir0
16 - Nebula

Hi @jhe1 

 

I understood what you are trying to do, but i dont think that building a macro to run each time with different columns of the same dataset is a good idea. They usually work good with the same columns and different rows.

 

But if you really want to go ahead, you could use the field info to get the field names,put a index on the fields that gonna be imported by each iteraction, rename then before of the macro to a standard name, and rename then to the original name after the macro. Too much work i think.

jhe1
6 - Meteoroid

Hi KSowers, 

 

thank you for your comment. I was on vacation over the past week. So just got time to reply now. 

 

For the function, I mean to put the calculation process in one function with column name as the argument. Then call the function by passing each column name.

jhe1
6 - Meteoroid

Hi Felipe_Ribeir0, 

 

many thanks for your reply. Yes, you correctly understood what I meant. Thank you!

 

I implemented the process with Python. However, I found your explanation why macro is not a good idea for this case excellent! I think your suggestion should be a potential solution in this case. 

 

Best, 

Jing

Labels