简体   繁体   English

Excel 如果 b 中的值大于 0,则计算 a 中的唯一值

[英]Excel count unique values from a if values from b are grather than 0

I have 2 columns.我有 2 列。 I want to count the unique values from A if the corresponding value from b is grather than 0如果来自 b 的相应值大于 0,我想计算来自 A 的唯一值

A一个 B
John约翰 2 2
Mary玛丽
John约翰 2 2
John约翰
Sally莎莉 2 2
Terry特里 1 1
Terry特里

In the above example the result will be 3 (john + sally + terry).在上面的示例中,结果将是 3 (john + sally + terry)。 I am using excel 2016. I saw same example with Unique but this function is not available.我正在使用 excel 2016。我看到了与 Unique 相同的示例,但此 function 不可用。 Is there any other way of achieving this without using pivot?有没有其他方法可以在不使用 pivot 的情况下实现这一目标?

You can use this complex formula:您可以使用这个复杂的公式:

=SUM(IF(FREQUENCY(IF(LEN(IF($B$1:$B$7>0,$A$1:$A$7,""))>0,MATCH(IF($B$1:$B$7>0,$A$1:$A$7,""),IF($B$1:$B$7>0,$A$1:$A$7,""),0),""),IF(LEN(IF($B$1:$B$7>0,$A$1:$A$7,""))>0,MATCH(IF($B$1:$B$7>0,$A$1:$A$7,""),IF($B$1:$B$7>0,$A$1:$A$7,""),0),""))>0,1))

在此处输入图像描述

To better understand it, I suggest you break it up into it's component parts and examine the results (or use the Formula evaluation tool).为了更好地理解它,我建议您将其分解为各个组成部分并检查结果(或使用公式评估工具)。

In some earlier versions of Excel, you may need to "confirm" this array-formula by holding down ctrl + shift while hitting enter .在 Excel 的一些早期版本中,您可能需要通过按住ctrl + shift的同时按enter来“确认”这个数组公式 If you do this correctly, Excel will place braces {...} around the formula as observed in the formula bar如果您正确执行此操作,Excel 将在公式周围放置大括号{...} ,如公式栏中所示

In Office 365 this could be done like this: =COUNTA(UNIQUE(FILTER(A:A,B:B>0)))在 Office 365 中,可以这样完成: =COUNTA(UNIQUE(FILTER(A:A,B:B>0)))

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

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