[英]Count unique values in excel based on multiple criteria
I've got a spreadsheet with 3 columns and want a formula to count the unique values in column A based on 3 criteria against B and C. 我有一个包含3列的电子表格,希望有一个公式根据B和C的3个条件来计算A列中的唯一值。
Below is an example of the data and desired output. 以下是数据和所需输出的示例。 E2:H2 is where the formula should go.
E2:H2是公式应该去的地方。 The data contains blank values in column C. Column B is the result of a vlookup.
数据在C列中包含空白值。B列是vlookup的结果。
A B C D E F G H
1 Email List Date 1/1/19 1/2/19 1/3/19 1/4/19
2 1@1.com X 1/1/19 2 1 1 0
3 2@2.com Y 6/3/19
4 3@3.com Z 2/2/18
5 1@1.com X 9/1/19
6 4@4.com X 5/2/19
7 1@1.com X
8 5@5.com X 4/1/19
9 4@4.com X 3/2/19
10 5@5.com X 4/3/19
I want to find the number of unique values in column A where column B == X and column C falls within a particular month (provided by E1:H1). 我想在A列中找到唯一值的数量,其中B列== X并且C列在特定月份内(由E1:H1提供)。
I'd like to avoid using multiple pivot tables for each date range if possible. 如果可能的话,我想避免为每个日期范围使用多个数据透视表。
I've tried two formulas which don't work. 我尝试了两个无效的公式。
{=SUM(IF((B2:B10="X")*(C2:C10>=E$1)*(C2:C10<F$1), 1 / COUNTIFS(B2:B10, "X", C2:C10, ">="&E$1, C2:C10, "<"&F$1, A2:A10, A3:A10)), 0)}
=SUMPRODUCT(((B2:B10="X")*(C2:C10>=E$1)*(C2:C10<F$1)) / (COUNTIFS(A:A, A2:A10, B2:B10, "X", C2:C10, ">="&E$1, C2:C10, "<"&F$1)))
I've seen similar questions in Stack Overflow but none worked for me. 我在Stack Overflow中看到了类似的问题,但没有一个对我有用。
Any help appreciated. 任何帮助表示赞赏。
You could implement some BOOLEAN
logic and check if MONTH
and YEAR
in C:C
are the same as the lookup month and multiply that against your "x" criteria in column B:B
: 您可以实现一些
BOOLEAN
逻辑,并检查C:C
中的MONTH
和YEAR
是否与查找月份相同,然后将其与B:B
列中的“ x”条件相乘:
Formula in E2
: E2
公式:
=SUM(--(FREQUENCY(IF((MONTH($C$2:$C$10)=MONTH(E1))*(YEAR($C$2:$C$10)=YEAR(E1))*($B$2:$B$10="X"),MATCH($A$2:$A$10,$A$2:$A$10,0)),ROW($A$2:$A$10)-ROW($A$2)+1)>0))
Note: It's an array formula and needs to be confirmed through Ctrl Shift Enter
注意: 这是一个数组公式,需要通过Ctrl Shift Enter进行确认
Drag right... 向右拖动...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.