Forum Discussion
dennistb95
Oct 26, 2023Copper Contributor
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?
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))) )
- LorenzoSilver Contributor
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))) )
- dennistb95Copper Contributor
Lorenzo Wauw, this is what I need!! Many thanks! It is working like a charm
- LorenzoSilver Contributor
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