Forum Discussion

ReneeHansen's avatar
ReneeHansen
Qrew Member
2 years ago

Random "number assignment"

Hi! 

I built a junior rodeo app and I'm wondering if there's a way I can do a "random draw" for scorecards.

We have to generate a random sequence of numbers depending on how many players are in that event. Right now we're using a random number generator, and just taking whatever number order they generate and assigning it manually for over 1,000 scorecards. We have a report, and it's okay to type the number down the list, but it would be great if QB could generate a random draw for us! 

Here's how it works: The "draw" determines when they come out of the gate - when it's their turn.

Event A has 14 players, they need to be assigned random numbers.

Event B has 12 players and need a random number assigned. etc and so on.

Does anyone have any ideas?



------------------------------
Renee Hansen
------------------------------

15 Replies

  • If you are ok with a slow pipeline/jinja solution (although it would be still faster than you manually copy pasting) ,It can generate random ID

    I tried updating a record with following formula and it works great 

    {{ range(1, 10000) | random }}


    ------------------------------
    Prashant Maheshwari
    ------------------------------
    • ReneeHansen's avatar
      ReneeHansen
      Qrew Member
      That's a workable option! How would this work?

      ------------------------------
      Renee Hansen
      ------------------------------
    • ReneeHansen's avatar
      ReneeHansen
      Qrew Member
      Actually I mean, how would I set it up?

      ------------------------------
      Renee Hansen
      ------------------------------
      • PrashantMaheshw's avatar
        PrashantMaheshw
        Qrew Captain
        Create two fields on your records you wish to generate random number
        • checkbox - GenerateRandom
        • text - RandomScore
        Create a pipeline
        • Trigger- When records are updated , when GenerateRandom=True
        • Update field RandomScore 
        • Value {{ range(1, 10000) | random }}


        ------------------------------
        Prashant Maheshwari
        ------------------------------
  • DonLarson's avatar
    DonLarson
    Qrew Commander

    Renee,

    Did you ever solve this with pure QB?  I have new business case that needs this as well.



    ------------------------------
    Don Larson
    ------------------------------
    • PrashantMaheshw's avatar
      PrashantMaheshw
      Qrew Captain

      Hi Don , 

      i did a couple of tries and the most relevant answer was using the shuffle filter in Jinja but it's not supported via quickbase. I've opened a ticket to ask them if there is a way to emulate the same. 



      ------------------------------
      Prashant Maheshwari
      ------------------------------

      • DonLarson's avatar
        DonLarson
        Qrew Commander

        I have made some minor progress on this.   I took the Jinja expression you used

        {{range(1,20000)|random}}

        to populate a field on the records.   That works great as you described.

        Next I am trying to pull that field and the RID's into a JSON file and order them by the random number field.

        Then I want to extract the RID's from the first 10 records in order by the random numbers.

        That will give me my pool of randomly selected records for the business process.

        Then I will clear the random field in the original data set.

        The hard part is the JSON step but once I have a framework, this should be repeatable for other cases.



        ------------------------------
        Don Larson
        ------------------------------