# Auto Generate Random(ish) Group Assignments

Solved
877 3
cancel
Showing results for
Did you mean:
4 - Data Explorer

I'm trying to randomly assign one of four Group IDs (AlphaGroup, BetaGroup, GammaGroup, DeltaGroup) to all existing/new records in my database whether they're imported in bulk or added manually. I've been using this formula—however since some of my records will be imported in bulk, their created time remains the same and gives them all the same Group ID). I also have First Name, Last Name, Email, and other fields that could potentially be useful here. Any idea how to address this? Thanks!

``````IF(
SECOND( CREATED_TIME() ) < 15,
"AlphaGroup",
IF(
SECOND( CREATED_TIME() ) < 30,
"BetaGroup",
IF(
SECOND( CREATED_TIME() ) < 45,
"GammaGroup",
"DeltaGroup"
)))``````

1 Solution

Accepted Solutions
18 - Pluto

Probably something like this:

``````IF(
MOD(Autonumber - 1, 4) = 0, 1,
IF(
MOD(Autonumber - 2, 4) = 0, 2,
IF(
MOD(Autonumber - 3, 4) = 0, 3,
4
)
)
)``````
3 Replies 3
18 - Pluto

How about using an autonumber field and whether it's divisible instead?  Less random(ish) than your current solution, but would split evenly?

4 - Data Explorer

Thanks @TheTimeSavingCo. That sounds like a great solution. How would you write the code/formula assuming we create an autonumber field?

18 - Pluto

Probably something like this:

``````IF(
MOD(Autonumber - 1, 4) = 0, 1,
IF(
MOD(Autonumber - 2, 4) = 0, 2,
IF(
MOD(Autonumber - 3, 4) = 0, 3,
4
)
)
)``````