如何计算 Excel 中的唯一值?
我们经常需要报告购买的客户的唯一数量、我们库存中的产品数量、我们业务覆盖的区域列表。
在本文中,我们将解释如何计算 excel 列中的唯一值。
样本数据:
我们提供了包含客户和购买的产品两个字段的示例数据。需要创建一个摘要报告来显示我们的数据库中有多少客户。
方法一:使用数组公式
句法:
COUNTIF (range, criteria)
Range – List of data
Criteria – A number or text. Apply on input range
Return an integer value that match the criteria
第 1 步:在 D5 单元格中输入“客户数量”
第 2 步:在单元格 E5 中写入以下公式,以计算唯一客户数。我们使用数组公式来计算唯一计数,因此请确保您必须按Ctrl+Shift+Enter ,如下图 1 所示:
=SUM(1/COUNTIF(B2:B30,B2:B30))
单元格 E5 中的公式应该用“{}”花括号覆盖,如下图 2 所示:
![](https://mangodoc.oss-cn-beijing.aliyuncs.com/geek8geeks/How_to_Count_Unique_Values_in_Excel?_1.jpg)
图 1
![](https://mangodoc.oss-cn-beijing.aliyuncs.com/geek8geeks/How_to_Count_Unique_Values_in_Excel?_2.jpg)
图 2
方法 2:使用公式(适用于 MS Office 365 用户)
如果您使用的是 MS Office 365,则可以使用以下公式计算唯一计数。
=COUNTA(UNIQUE(B2:B30))
句法
COUNTA(Value1, Value2,…)
Value1 – a cell, excel range, array of text
Return count of non-empty cells
UNIQUE(array, by_col, exactly_once)
Array - list of data value to return unique
By_col – Boolean value [True - return unique columns / False – return unique rows]
Exactly_once – Boolean value [return only distinct values]