Hi @nikolai I’ve tried to setup something similar before, and I think the ‘modulo’ operator might be helpful too! For example, in this repeating group I have 30 Support Email Things, and each of them have a number (1 through 30):

Editor: faye-demo-app | Bubble Editor

Preview: https://faye-demo-app.bubbleapps.io/version-test/modulo-roundrobin

This repeating group does a Search for Support Emails, and then uses conditional formatting to change the color of each cell, so that they are separated into 6 different groups (or colors):

In this expression, we’re using <-modulo->6 because there are 6 groups. If we only had 5 we would change each expression to <-modulo->5. I’m not 100% sure about how to explain modulo, but my understanding is that modulo always gives you the remainder. So for the first 8 Support Emails, the expressions mean:

- 1<-modulo->6 is 1 (The remainder of 1 divided by 6 is 1)
- 2<-modulo->6 is 2 (The remainder of 2 divided by 6 is 2)
- 3<-modulo->6 is 3 (The remainder of 3 divided by 6 is 3)
- 4<-modulo->6 is 4 (The remainder of 4 divided by 6 is 4)
- 5<-modulo->6 is 5 (The remainder of 5 divided by 6 is 5)
- 6<-modulo->6 is 0 (The remainder of 6 divided by 6 is 0)
- 7<-modulo->6 is 1 (The remainder of 7 divided by 6 is 1)
- 8<-modulo->6 is 2 (The remainder of 8 divided by 6 is 2)

(and this repeats for all 30)

If you don’t store each Support Email in the database on a User, you can use an advanced constraint to filter them into individual groups:

(Note: If a User has a Group Number (1 through 6), the expression would be: "Advanced: This SupportEmail’s Number <-modulo-> 6 is Current User’s Group Number).

If you are creating the Support Emails one by one over the course of the day, each of those would be assigned a number (1 through 30) as they are created using “Ticket Number = Search for SupportEmails:count + 1”.

Then you can assign each Support Email a Group Number (to put them into one of the six groups evenly), using the expression: Group Number = “Search for SupportEmails:count+1<-modulo-> 6”. The result of that expression will assign it to either 1, 2, 3, 4, 5, or 0.

If you want to assign all of the Support Emails a Group Number at one time, you can use the “Make Changes to a List of Things” action, and set the Group Number in the same way using “Group Number = This Support Email’s ticket number <-modulo->6” to get a result of 1,2,3,4,5 or 0.

Then, the Users in your app can have a corresponding Group Number field (1,2,3,4,5 or 6). You can query the corresponding Support Emails (which match the User’s group number) using “Do a Search for Support Emails” (constraint: Group Number = Current User’s Group Number").

Note: for the 6th support person, their Group Number could still be ‘6’, but the constraint will be “Group Number = 0”, since every 6th Support Email has a Group Number of 0 (since every 6th item for <-modulo->6 equals 0).

I hope I didn’t make this super confusing - if you have any questions or need help setting this up in your app feel free to let me know!