I have a Google Sheet with 1000 rows, each is a different company. I would like to assign them randomly into 5 equal groups. How can I do it?

huangapple go评论66阅读模式
英文:

I have a Google Sheet with 1000 rows, each is a different company. I would like to assign them randomly into 5 equal groups. How can I do it?

问题

我有一个包含1000行的Google表格,每一行都是不同的公司。我想将它们随机分成5个相等的组。我应该如何做?

我尝试在一个列中随机生成从1到5的数字,但问题是每个组包含不同数量的行。

英文:

I have a Google Sheet with 1000 rows, each is a different company. I would like to assign them randomly into 5 equal groups. How can I do it?

I have tried to randomize a number from 1 to 5 in one column, but the problem is that wach group contains a different amount of rows.

答案1

得分: 1

=let(
names,tocol(A1:A,1),
groups,5,
stableRandomSortOrder,lambda(x,x)(randarray(counta(names))),
wraprows(sort(names,stableRandomSortOrder,1),groups,))

英文:

Also possible to achieve the same thing for any number of company names in A1:A and any number of required groups without the MAP or SEQUENCE :

=let(
names,tocol(A1:A,1),
groups,5,
stableRandomSortOrder,lambda(x,x)(randarray(counta(names))),
wraprows(sort(names,stableRandomSortOrder,1),groups,))

</details>



# 答案2
**得分**: 0

***更新后的公式:***

```excel
=let(grp,3,len,counta(A:A),Δ,(grp*ceiling(len/grp)),sort(query(tocol(map(sequence(grp),lambda(Σ,wraprows(Σ,Δ/grp,Σ)))),&quot;offset &quot;&amp;Δ-len),lambda(Σ,Σ)(randarray(len,1)),1))

你可以尝试:

=sort(tocol(map(sequence(5),lambda(Σ,wraprows(Σ,200,Σ)))),lambda(Σ,Σ)(randarray(1000,1)),1)

I have a Google Sheet with 1000 rows, each is a different company. I would like to assign them randomly into 5 equal groups. How can I do it?

英文:

Updated formula:

=let(grp,3,len,counta(A:A),Δ,(grp*ceiling(len/grp)),sort(query(tocol(map(sequence(grp),lambda(Σ,wraprows(Σ,Δ/grp,Σ)))),&quot;offset &quot;&amp;Δ-len),lambda(Σ,Σ)(randarray(len,1)),1))

Can you try:

=sort(tocol(map(sequence(5),lambda(Σ,wraprows(Σ,200,Σ)))),lambda(Σ,Σ)(randarray(1000,1)),1)

I have a Google Sheet with 1000 rows, each is a different company. I would like to assign them randomly into 5 equal groups. How can I do it?

huangapple
  • 本文由 发表于 2023年3月31日 23:46:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/75900432.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定