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

Top 10 of multiple strings from a field

thrnma
7 - Meteor

Hello!

 

I am working on a flow where I want to pull out the top 10 invoices from certain data sources. I have a flow which contains a macro that brings in all the files I need. An example of the data is:

BA100
BA77
BA75
BA74
CF99
CF95
CF86
CF2
GH67
GH65
GH34
GH4

 

I am able to get the data in to this order, so it is sorted from high to low, and then split by code. However, I cannot figure out how to get it so I have the top two values from each code only, so it looks like this:

BA100
BA77
CF99
CF95
GH67
GH65

 

I tried the following:

- Limiting the number of files per output. This created hundreds and hundreds of files

- Getting the top 6 invoices from the full data set. This would grab, for example, 4 BA invoices and 2 CF, but no GH invoices.

 

I was thinking maybe assigning record ids so I had BA1, BA2, CF1, CF2 etc, but cannot figure this out either.

 

Thank you for any help!

2 REPLIES 2
Emil_Kos
17 - Castor
17 - Castor

Hi @thrnma,


Use the sample tool with the below configuration:

 

Emil_Kos_0-1616426993612.png

 

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @thrnma,

 

Once you have your values in order you can use a sample tool, using the group by option (at the bottom of the configuration) to group by your code field. You'll then get the first N records for each Code.

 

Jonathan-Sherman_1-1616427125201.png

 

 

Jonathan-Sherman_0-1616427100350.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.


Kind regards,

Jonathan

Labels
Top Solution Authors