SOLVED

# Random distribution of a fixed amount of numbers

Copper 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?

3 Replies
best response confirmed by dennistb95 (Copper Contributor)
Solution

# Re: Random distribution of a fixed amount of numbers

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

# Re: Random distribution of a fixed amount of numbers

@Lorenzo Wauw, this is what I need!! Many thanks! It is working like a charm

# Re: Random distribution of a fixed amount of numbers

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

1 best response

Accepted Solutions
best response confirmed by dennistb95 (Copper Contributor)
Solution

# Re: Random distribution of a fixed amount of numbers

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