Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.

Alteryx Designer Desktop Discussions

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

How to distribute work evenly but with individual set limits. Iterative macro?

rfoster7
11 - Bolide

Let us say you have two inputs. 

 

input one, a list of items that need to be distributed

 

rfoster7_0-1680718791561.png

 

 

 

input two, a list of people to distribute them too, but with a limit on how many they can take

 

rfoster7_1-1680718822503.png

 

 

Let's say you want to randomly sort input one, then distribute to the list of people, up to their limits. Any remainder after everyone has reached their limits goes to a final overflow list. 

 

The distribution limit is where I run into issues. If the distribution was even, I could just use a tile tool or a multirow tool.

 

rfoster7_2-1680718893034.png

rfoster7_3-1680718918799.png

 

 

 

 

but I need to add in something so that when a person hits their distribution limit, it cuts them off. 

 

I tried doing a second multi-row tool to divide out any element > than the distribution limit, but it doesn't work as wanted. Because what I really need is for the distribution to continue until everyone reaches their limit so that the overflow are the ones left at the end. 

 

I'm sure there is a way to use an iterative macro to do this, but I don't know how. Hoping someone can help. I am attaching example files of some fake data in anyone cares to lend a hand. 

 

 

 

4 REPLIES 4
PHinkel
7 - Meteor

Hi @rfoster7 ,

Take a look at the attached workflow and let me know what you think.

You can use the Generate Rows tool to create a row for each "open slot of work" that a team member has and then Join on Record Position to assign that work with the non-joined work falling into the "Overflow" bucket.

 

We already randomly sort, so it may not matter that we assign work to one person up to capacity and then the next, but if this ever becomes a concern you could sort the output of Generate Rows by RowCount to assign all "RowCount = 1" lines first.

 

Feel free to reach out with any questions!

PHinkel_0-1680721066591.png

 

rfoster7
11 - Bolide

I like where you are heading. Unfortunately, I left out a component that I thought was irrelevant, but isn't. The initial sort order of the distribution list is only semi random. We sort files by three columns. 1. length of time its been waiting, 2. a Y/N for if the claim is a certain type and only finally 3> random of everything waiting less than 1 day that is not of that particular Y/N value. 

 

So unfortunately, all the old long time waiting claims and Y type claims will get sent to the first couple people, which is not wanted. 

 

However, I think your solution might work if I change your generate rows tool so that instead of person 1 having rows 1 through 24 and person 2 rows 25 through 50, instead we round robin the numbers to each person's limit.

 

So what I need is something like

 

Jan    1

Robert      2

Karl      3

Athena     4

Jan    5

Robert    6

Karl  7

Athena 8

...

 

 

 

I think you might have a winner. I'll try that and, if it works, I'll accept your solution.

EDIT: And I totally missed that you already had a solution for that in your reply. Perfect! Thanks so much!

SPetrie
13 - Pulsar

Here is another option using an iterative macro as you were initially thinking. It randomized the list and then assigns it to each tech and drops them off after their limit is reached.

Because all items go through the iteration, the two inputs go through a union beforehand.

SPetrie_0-1680724699950.png

SPetrie_1-1680724819231.png

Assigned jobs come out of the assigned anchor and over flow jobs come out the other.

SPetrie_4-1680724969198.png

 

SPetrie_3-1680724932915.png

 

 

 

More involved than the other solution, but more fun to create too. So there is that :)

 

 

rfoster7
11 - Bolide

I appreciate the work on it. This is closer to what I was imagining. While I'm going with the first solution IRL, I am certainly studying this so I learn more about iterative macros!

Labels