简体   繁体   English

通过Excel中的两个条件获得唯一计数

[英]Get unique count with two conditions in excel

How to get the count of unique keys with two conditions. 如何在两个条件下获得唯一键的计数。 Ex. 防爆。 Room C3 dated 2/1 C3室,日期2/1

Answer : 2 Since 123 and 124 is only the unique keys under C3 and 2/1 答案:2因为123和124只是C3和2/1下的唯一键

Keys Room. Dates
123  C1    2/1
125  C1    2/4
124  C3    2/2
123  C3    2/1
124  C3    2/1
123  C3    2/1

With Excel a unique count has always been a challenge. 使用Excel唯一计数一直是一个挑战。 Approaches involve either long, convoluted array formulas (see here or this question ) or using Pivot tables as an intermediate step. 方法涉及长而复杂的数组公式(请参阅此处此问题 ),或将数据透视表用作中间步骤。

With the new Dynamic Array functions currently in preview for Office 365 Insider builds, this is a piece of cake, though. 不过,借助Office 365 Insider构建中当前正在预览的新动态数组功能,这可是小菜一碟。

This formula entered into just one single cell, no copying, will filter the data to return only the unique rows: 仅在一个单元格中输入此公式,不进行复制,该公式将过滤数据以仅返回唯一行:

=UNIQUE(FILTER(B4:D9,(C4:C9=G2)*(D4:D9=G3),""))

The screenshot shows that the data automatically "spills" into the rows below. 屏幕快照显示数据自动“溢出”到下面的行中。

在此处输入图片说明

If you are only interested in the final count, then filter only the first column and count the resulting data in one formula: 如果仅对最终计数感兴趣,则仅过滤第一列,并在一个公式中计算结果数据:

=COUNT(UNIQUE(FILTER(B4:B9,(C4:C9=G2)*(D4:D9=G3),"")))

在此处输入图片说明

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

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