Alteryx Designer Desktop Discussions

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

First N records based on dynamic condition

alastair_ross
5 - Atom

Hi Everyone,

 

Hoping someone might be able to help me here as I am finding nothing so far and running out of hair to pull out.

 

I am creating an App which will allow the user to select some input values, then merge this with some fixed data to produce an XML file as an output. The user will need to enter a store location, and a number of records per store required.

 

The part I am stuck on is that I need to user to be able to specify a potentially unlimited number of stores, and generate the right number of records. I can see how to select the first N records in total, but not "the first N records for each site."

 

Input data would look like this:

Location                     Number required

Manchester Store           5

Leeds Store                    10

etc etc

 

At the moment I have found a very clunky way of doing it but it is not scalable so hoping someone knows a clever way of achieving this.

 

Attached is the section of the workflow with some sample data.

 

Many thanks in advance

 

Al

3 REPLIES 3
Ben_H
11 - Bolide

Hi @alastair_ross,

 

I've simplified this significantly.

 

Ben_H_0-1681374999977.png

 

First I've separated off the config part, so there is just one place you have the 5 or 10 or whatever number of records you need.

 

Then all I've done is create a unique ID (starting at 1) for each group of records (location) I've done this with the tile tool but there are other ways,

 

Then simply joined the number required and said [Location ID] <-= [Number Required]

 

Ben_H_1-1681375208075.png

 

Regards,

 

Ben

DataNath
17 - Castor

Hey @alastair_ross, how does this look? I've built out a Batch Macro that ought to handle this fine:

 

DataNath_0-1681375178667.png

 

The inside of the macro looks like so:

 

DataNath_1-1681375194600.png

 

What's happening here is each iteration, we look at the next record of your Summarize tool (which has your location and the number of records to select). These values then feed into the macro via the Control Parameter and the location field updates the filter whilst the 'number of records' field updates the N of the Sample tool. The macro then unions the results of all runs after completion.

 

I've attached the packaged workflow here which contains the macro within it. Hopefully this helps - if not, please let us know the issue and we can keep working on a fix! And feel free to ask questions if you'd like more information.

alastair_ross
5 - Atom

Hey, wow thanks for the fast response, and two solutions that do exactly what I needed. 

Many thanks!!

Labels