每组中随机选一行
Excel的A列是分组,B列是明细。
A |
B |
|
1 |
Group |
Name |
2 |
A |
John |
3 |
A |
Joe |
4 |
A |
Ann |
5 |
A |
Susan |
6 |
A |
James |
7 |
A |
Mary |
8 |
A |
L .orraine |
9 |
B |
Joseph |
10 |
B |
Sinead |
11 |
B |
Michelle |
12 |
B |
Breege |
13 |
B |
Tom |
14 |
B |
Francis |
15 |
B |
Conan |
16 |
B |
Cait |
17 |
B |
Ronan |
18 |
B |
Deirdre |
19 |
B |
Aoife |
20 |
B |
Sile |
21 |
B |
Sarah |
22 |
C |
Lisa |
23 |
C |
Micky |
24 |
C |
Pat |
25 |
D |
Miles |
26 |
D |
Olivia |
27 |
D |
Avril |
28 |
D |
Conor |
29 |
D |
Jane |
30 |
D |
Robyn |
31 |
D |
June |
要求从每组中随机选出一行。
E |
F |
|
1 |
Group |
Name |
2 |
A |
Mary |
3 |
B |
Sarah |
4 |
C |
Micky |
5 |
D |
Miles |
使用 SPL XLL
=spl("=E(?).sort(rand()).group@1(Group)",A1:B31)
函数 E 将片区解析为表格,sort(rand()) 随机排序,group@1 分组并取每组第 1 条记录。
来源:https://www.reddit.com/r/excel/comments/1cn10qm/randomly_selecting_one_name_from_each_group_in/
英文版