How to Auto Add Row to a List of Options Equally

I am working with 2 Tables…

[Table 1] → Employee List
[Table 2] → Group List

Every employee needs to be assigned a group through a lookup column, and it doesn’t matter what group they’re assigned to. The group will also do a reverse lookup by employees to see what employees are in it’s group.

Here is the challenge.

Every employee needs to be assigned a group automatically when a row is created, and all groups need to be weighted equally in terms of row count.

So for example, if I have 200 Employees & 8 Groups, they need to be divided so each group contains 25 employees. And as employees are added, they need to be auto added to the group with the least amount of employees.

Help is super appreciated!

Hi @Micah_Lucero
Very cool use case. Here is my proposal !

  1. Start by creating a count of employee in your groups, and add a colummn to check if the group has the lowest number of employee in it


  2. Create the tricky button to add people in people list and auto choosse a group :stuck_out_tongue. This button will create a people and choose the group with the minimum number of people (if checkbox = true). If more than 1 group has lowest number, it will be made by random

  1. Thats it, live action now !


And the embed doc :wink: Have Fun !

Please let us know if that fit to your needs !



A few precisions

  • It works obviously with any number of groups
  • as it is now you have to use the button to add a new people, otherwise it won’t work

that is indeed a nice puzzle as @Quentin_Morel said, I propose a different set up.

I created a table with 187 employees (I use dummy data). and permit the user to select one of the groups that is left, in this case only 3. I created the groups using a randomItem() in the value for new rows.

the real trick is found here:

and the table I reference you find here:

enjoy the puzzle!

cheers, Christiaan


Hey nice one @Christiaan_Huizer, but do you confirm you have to manually chose an “available” group ?
Ly proposal is the one I found to perform the trick automatically. Also tried to put the RandomItem() directly in people database, but it processes again when you add a new people, even fit update put to false…

1 Like

indeed, the user has in the example the choice to pick one of them. Users often appreciate a bit of choice.

to avoid this heavy work, we can use the option value for new rows to fill out the one that has the lowest number.

1 Like

Thank you both so much for your detailed responses! You guys really make Coda a special platform with the quality support and creative solutions.

I was able to fuse together pieces of both solutions into something that works! Thanks again! @Quentin_Morel @Christiaan_Huizer


Always a pleasure to help ! FYI I also implemented in the doc a page with “autofill for new row”, so that you dont need to have buttons, it will auto select a group when you add a row in people database.

Enjoy then !

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.