[英]Excel: count unique values using SUMPRODUCT with multiple conditions
好的,我有一個求和產品,可以為我提供一列中唯一值的計數:
=SUMPRODUCT((F2:F38<>"")/COUNTIF(F2:F38,F2:F38))
因此,如果我有數字: 1, 2, 3, 1, 5, 6, 2, 5, 2
它將返回5
。
但是我要做的是根據另一個數字來計算唯一值的數量,例如:
Name: Sales:
Mike 2
Bob 1
Gary 1
Mike 5
Bob 6
Gary 1
Mike 3
Bob 4
Gary 2
Mike 1
Bob 2
Gary 6
Mike 3
Bob 1
Gary 1
Mike 1
Bob 3
Gary 4
可以說,“名稱” Mike有4
個unique values for "Name" Bob, and
5個unique values for "Name" Bob, and
unique values for "Name" Gary. This is because for "Name" Mike there are the numbers
4個unique values for "Name" Gary. This is because for "Name" Mike there are the numbers
unique values for "Name" Gary. This is because for "Name" Mike there are the numbers
2 5
3
1個
3
1
, so the unique numbers are
2 5
3
1
and therefore the count would return
4`。
有辦法嗎?
這是一個解決方案。
在底部插入一個單元格,其中包含您要為其計算唯一值的值。因此在工作表底部添加“ Gary”。 在“銷售”列的右側創建另一個列,稱為“ NameValue”。 在此列中創建一個公式:
=IF(A2=$A$10,B2,"") <-Where $A$10 is the location of "Gary"
然后在新列的底部插入以下公式:
=SUM(IF(C2:C6<>"",1/COUNTIF(C2:C6, C2:C6), 0)) <-Where C2:C6 is your range we just create from above.
在鍵入此公式時,您可能需要按Ctrl + Shift + Enter。現在,您可以將A12的值更改為名稱列中的任何值,這將吐出唯一計數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.