计算一列单词出现的次数,找出第二、第三个最常见的

时间:2021-06-06 13:54:01

标签: excel google-sheets excel-formula google-sheets-formula

我有一个公式可以找到频繁出现的文本并且效果很好。

=INDEX(Rng,MATCH(MAX(COUNTIF(Rng,Rng)),COUNTIF(Rng,Rng),0))

如何调整以找到第二高、第三高?

3 个答案:

答案 0 :(得分:1)

第二:

=LARGE(A2:A; 2)

第三:

=LARGE(A2:A; 3)

更新 1:

使用查询:

=QUERY(A:A, 
 "select A,count(A) where A is not null group by A label count(A)''")

enter image description here

要仅获得第二或第三,您可以使用以下索引:

=INDEX(QUERY(A:A, 
 "select A,count(A) where A is not null group by A label count(A)''"), 2)

更新 2:

=INDEX(QUERY({'Data Entry Errors'!I:I}, 
 "select Col1,count(Col1) where Col1 is not null group by Col1 order by count(Col1) desc limit 3 label count(Col1)''"),,1)

答案 1 :(得分:1)

在 Google 表格中,要获取 A2:A 列中每个单词的出现次数,请使用以下命令:

=query(A2:A, "select A, count(A) where A is not null group by A order by count(A) desc label count(A) '' ", 0)

要获得第二个和第三个结果以及它们出现的次数,请使用:

=query(A2:A, "select A, count(A) where A is not null group by A order by count(A) desc limit 2 offset 1 label count(A) '' ", 0)

要仅获取按出现次数排在第二位和第三位的名称,请使用以下命令:

=query( query(A2:A, "select A, count(A) where A is not null group by A order by count(A) desc limit 2 offset 1 label count(A) '' ", 0), "select Col1", 0 )

答案 2 :(得分:0)

对于 Excel 365

假设我们在 A 列中有从 A2A66 的数据,例如:

20
11
27
18
3
31
2
30
8
1
18
32
3
5
4
6
4
1
22
11
2
46
33
34
25
53
37
9
20
2
12
4
5
4
23
39
19
4
28
22
5
16
24
7
6
10
13
31
56
23
1
16
27
39
1
6
11
6
20
11
24
12
9
29
12

我们想要一个频率表,列出最频繁的值、第二频繁的值、第三个等等。

最简单的方法是构建数据透视表,但如果您需要公式方法,则在B2中输入:

=UNIQUE(A2:A66)

C2中输入:

=COUNTIF(A$2:A$66,B2)

我们现在按 C 对列 B:C 进行排序。在 D2 中输入:

=SORTBY(B2:C35,C2:C35,-1)

enter image description here