Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

even groups


rivet

This topic is 7839 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have a list of names that can vary. I have to spread them equally into six groups, where group six would have a minimum of two, or a maximum of the other groups.

So.. groups one to five will be equal size, and group six will handle the carry over.

Link to comment
Share on other sites

Rivet, try script below, you will need 3 global numbers and one number field in your db to hold the group number (GrpNo), RecCnt,RecCounter, and CurGrp are global numbers.

This works on found set.

SetGroup:

If [ Mod(Status(CurrentRecordCount), 6) = 0 ]

Set Field [ RecCnt, Status(CurrentRecordCount) / 6 ]

Else

Set Field [ RecCnt, Int(Status(CurrentRecordCount) / 6)+1 ]

End If

Set Field [ RecCounter, RecCnt ]

Set Field [ CurGrp, 1 ]

Go to Record/Request/Page

[ First ]

Loop

Set Field [ GrpNo, CurGrp ]

Set Field [ RecCounter, RecCounter - 1 ]

If [ RecCounter = 0 ]

Set Field [ RecCounter, RecCnt ]

Set Field [ CurGrp, CurGrp + 1 ]

End If

Go to Record/Request/Page

[ Next, Exit after last ]

End Loop

Link to comment
Share on other sites

If you have 26 people, you can't meet your standards:

Groups 1-5 are equal,

Group 6 has minimum of 2, maximum of number in other groups.

5x5 = 25, leaving 1 for group six.

5x4 = 20, leaving 6 for group six.

You'll have to change your standards.

Link to comment
Share on other sites

This topic is 7839 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.