简体   繁体   English

单个单词的平均计数的单单元格计算

[英]Single Cell Calculation of the Average Count of Unique Words

I have a dataset that looks as follows: 我有一个数据集,如下所示:

Apple
Banana
Banana
Carrot
Pear
Pear
Pear
Pear
Pear

I'd like to use a formula to find out on average how many times an item appears in the list. 我想使用一个公式来找出一个项目平均出现在列表中的次数。 At the moment, I create another table listing each item just once and then use COUNTIF to find the number of times each item appears: 此刻,我创建了一个仅列出每个项目一次的表,然后使用COUNTIF查找每个项目出现的次数:

Apple  1
Banana 2
Carrot 1
Pear   5

In another cell, I then average these numbers to reach a figure of 2.25. 然后在另一个单元格中,将这些数字取平均值,以达到2.25。

Is there a way to simplify this and calculate it using an (array?) formula in a single cell? 有没有一种方法可以简化此过程,并在单个单元格中使用(数组?)公式进行计算?

Thanks in advance! 提前致谢!

You do not require an array formula: 您不需要数组公式:

=COUNTA(A1:A9)/SUMPRODUCT(1/COUNTIF(A1:A9, A1:A9))

在此处输入图片说明

EDIT#1: 编辑#1:

It turns out that the average of the unique counts is actually: 事实证明,唯一计数的平均值实际上是:

=(total count of items) / (count of uniques) =(项目总数)/(唯一身份计数)

EDIT#2: 编辑#2:

To cover the entire column and exclude blanks, use the Array Formula : 要覆盖整列并排除空格,请使用Array Formula

=COUNTA(A:A)/SUM(IF(A:A<>"",1/COUNTIF(A:A,A:A ), 0))

Array Formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. 必须使用Ctrl + Shift + Enter输入 数组公式 ,而不仅仅是Enter键。

This is painfully slow to calculate, so I recommend restricting the cells in column A to something reasonable. 这是计算非常缓慢 ,所以我建议限制在A列单元格的东西合理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM