Alteryx Designer Desktop Discussions

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

How to incrementally update a number using Macro

Begnuser123
8 - Asteroid

Hello,

 

I have a workflow, where I need to filter by number and perform certain functions after that. I would like to incrementally update the filtered number, i.e. Tile_Num+1 so that the process runs incrementally and gives the results. I tried using update from macro but did not get success. Is there a sample workflow which i can refer to.

 

Thanks

4 REPLIES 4
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Begnuser123,

 

Is there a particular number you want to increment up to? Perhaps a max number in your data set?

 

I see there being two possible solutions, converting to either a batch macro or an iterative macro.

 

Batch Macro Approach:

 

Works by passing a unique list of "numbers" you have into the batch macro one by one (running the workflow once for each number). We use the control parameter tool to pass the list into the macro and an action tool to define how the list interacts with our workflow, in this example i'm passing that list into the filter tool to change the number we're filtering for on each run.

 

Workflow:

Jonathan-Sherman_0-1606390618081.png

 

Macro:

Jonathan-Sherman_1-1606390643669.png

 

 

Iterative Macro Approach:

 

Slightly more complex, and probably not the approach i'd take unless you feel comfortable with them. This method increases the starting value we are filtering for by 1 each time the macro loops using the [Engine.IterationNumber] variable (available in iterative macros). It will keep looping until the variable has reached the maximum number available in your data set to filter for.

 

Workflow:

Jonathan-Sherman_2-1606390878333.png

 

Macro:

Jonathan-Sherman_3-1606390903162.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached my workflow for you to download if needed.

 

Regards,

Jonathan

 

Begnuser123
8 - Asteroid

Hi @Jonathan-Sherman ,

 

Thank you for the solutions. 

 

The batch macro approach though convenient does not suit the purpose as everytime i need to input the number.

 

The iterative macro approach looks good. I tried to replicate in my solution but was getting errors on using similar to sample macro.

 

I have attached a  workflow using sample data. The workflow is to find out countries not present in every region and load the data of all regions to an excel. Please help to add the macro in the workflow.

 

Thank you in advance.

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Begnuser123,

 

I don't think you need to use a macro in this case, you could simply scaffold the data (combine a list of regions with a list of countries) and join on region and country to find the missing ones (which in my case fall out the right side of the join.

I've added my suggestion under your workflow so you can see the difference, we still retrieve the same list of 25 missing countries for Region1.

 

Jonathan-Sherman_0-1607085141217.png

 

If this solves your issue please mark the answer as correct, if not let me know! I've attached the updated workflow for you to download if needed.

 

Regards,

Jonathan

 

Begnuser123
8 - Asteroid

Thank you @Jonathan-Sherman . This works

Labels