Skip to main content
Solved

Auto Generate Random(ish) Group Assignments

  • December 16, 2022
  • 3 replies
  • 39 views

Forum|alt.badge.img+1

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" )))

 

Best answer by TheTimeSavingCo

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


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

TheTimeSavingCo
Forum|alt.badge.img+31

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


Forum|alt.badge.img+1
  • Author
  • New Participant
  • December 19, 2022

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


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


TheTimeSavingCo
Forum|alt.badge.img+31

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


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 ) ) )