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

Macro to process ALL records, 4 at a time

HomesickSurfer
12 - Quasar

Hi.

 

Need some help.  I would like to process all records of my input, though 4 records at a time.

I've used a sample tool configured with 'First N (4) rows', then a Join to match, then outputting unmatched remaining records to an external file...to repeat the process.  No luck getting either variation of macro (standard, batch, iterative) to loop through the records 4 at a time.

I suspect that i may need to crosstab/transpose the sample 4 records into a single row/record prior to passing through a macro, though based on some conditions, after the 4 are processed, may need to introduce the next 1 or 2 additonal record (record(s) #5, 6)

 

For example, 100 records, each with a single value of 1-10, process records #1-4, possibly #5, repeat same till all 100 are done.

9 REPLIES 9
DawnDuong
13 - Pulsar
13 - Pulsar

hi @HomesickSurfer 

I don't 100% understand the description TBH. Perhaps you can post a sample data input and expected output?

Coincidentally, someone just asked another question about processing 4 records, you may want to check out the responses here https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Split-output-to-multiple-sheets-based-...

Dawn.

HomesickSurfer
12 - Quasar

Hi @DawnDuong 

 

The referenced post doesn't satisfy what i am seeking.  Thank you for looking into my request.

I've attached a packaged workflow, macro and input data.  My sample doesn't loop/iterate

DawnDuong
13 - Pulsar
13 - Pulsar

@HomesickSurfer 

I think you need an iterative macro. I personally found the interactive trainings on Macros super good! https://community.alteryx.com/t5/Interactive-Lessons/tkb-p/interactive-lessons/label-name/Macros

Back to your use case, I attached here a simple iterative macro. Note the interface settings, which you can learn from the Interactive lessons shared above.

In this example, i only create a new column to note the iteration count when the records are processed.

SampleIterativeMacro2_15Oct2021.PNG

 

You can just add whatever process you want to do inside the macro to suit your specific use cases.

Dawn.

Christina_H
14 - Magnetar

@HomesickSurfer I think you can do what you need with either a batch macro or an iterative macro.  You currently have it set up as a batch macro.

 

To do this with a batch macro, you need to identify the batches outside the macro, then feed in all the data along with a list of the batches.  No need to sample to the first 4 rows within the macro, they will be fed in 4 at a time.

 

Alternatively, with an iterative macro you would sample the first 4 rows then feed them out of a separate output, and iterate the remaining records.  The macro would have two separate outputs, and you need to specify in the interface designer which output gets iterated back to the input.

 

You also don't have a macro input tool in your macro, you seem to be trying to update a text input with action.  Convert your text input to a macro input and it should work much better.

 

I'm happy to help further, but the best approach might depend on what you actually want to do with your data.  I assume the current process is a simplification for sharing, but what you're doing is possible without any macros at all!

Christina_H
14 - Magnetar

If it helps, here is your sample set up to work as a batch macro.

HomesickSurfer
12 - Quasar

Thank you @DawnDuong 

I am unable to download the file....getting a 'Failed - No file' with Chrome.

I'll attempt to recreate what you've posted in the image.

HomesickSurfer
12 - Quasar

Thank you @Christina_H 

I'll try your proposed solution and respond accordingly.

DawnDuong
13 - Pulsar
13 - Pulsar

Re-attached here. @HomesickSurfer 

SampleIterativeMacro2_15Oct2021.PNG

HomesickSurfer
12 - Quasar

Hi @DawnDuong 

 

This works!  Thank you.

I was able to get the iterations of 4 records each, resulting in 25 sets of totals as expected.

@Christina_H , I will also look deeper into your proposed solution.

 

Capture2.PNGCapture1.PNG

Labels
Top Solution Authors