Forum Discussion

dennistb95's avatar
dennistb95
Copper Contributor
Oct 26, 2023
Solved

Random distribution of a fixed amount of numbers

I am looking for a formula or function to distribute a fixed amount of numbers x over a designated area. This distribution has to be random. So for example, I want to distribute randomly the following amounts: 15x number 1, 14x number 2 and 4x number 3.

 

I am struggling to find the right solution and do need to do this 60 times with different distributions. Maybe there is an easy fix that I can not see right now...Can someone help me?

  • dennistb95 

    Assuming I understood... With inputs formated as Table (not mandatory) named DistribInput:

     

     

    in D3:

    =LET(
      amts, DROP(
        REDUCE(0,DistribInput[Time],
          LAMBDA(seed,t, VSTACK(seed, SEQUENCE(t,,INDEX(FILTER(DistribInput[Amount], DistribInput[Time]=t),1),0)))
        ), 1,
      ),
      SORTBY(amts, RANDARRAY(ROWS(amts)))
    )

     

  • Lorenzo's avatar
    Lorenzo
    Silver Contributor

    dennistb95 

    Assuming I understood... With inputs formated as Table (not mandatory) named DistribInput:

     

     

    in D3:

    =LET(
      amts, DROP(
        REDUCE(0,DistribInput[Time],
          LAMBDA(seed,t, VSTACK(seed, SEQUENCE(t,,INDEX(FILTER(DistribInput[Amount], DistribInput[Time]=t),1),0)))
        ), 1,
      ),
      SORTBY(amts, RANDARRAY(ROWS(amts)))
    )

     

      • Lorenzo's avatar
        Lorenzo
        Silver Contributor

        dennistb95 

         

        You're welcome. At the bottom of each reply you get here there's a link to Mark as solution... - This helps people who Search - Thanks

Resources