Using Countifs to count distinct values and multiple criteria?

元气小坏坏 提交于 2020-06-02 01:24:12

问题


I am trying to count how many brands a certain client has passed through. I essentially have two columns a client list and a brand column.

In some cases, there may be duplicates of the brand so I only need to count them once.

I have tried to use several variants Countifs/Sumifs formulas but to no success.

Totally lost and would appreciate any help Example

Thanks


回答1:


Try: =SUMPRODUCT(--(COUNTIFS($A:$A,$D2,$B:$B,$H$1:$H$10)>0))

You'll need to make a helper column which contains all the brands (no duplicates). The only thing that should change in the formula is $D2, which is the Client in question. So it will become $D3, $D4, etc.




回答2:


Here is a formula which does not require any helper column.

=SUMPRODUCT((($A$2:$A$13=$E2)*($B$2:$B$13<>""))/COUNTIF($B$2:$B$13,$B$2:$B$13&""))

The ($A$2:$A$13=$E2) checks that the name matches.

The ($B$2:$B$13<>"") just makes sure that any blanks are ignored (not counted as a brand).

The COUNTIF($B$2:$B$13,$B$2:$B$13&"") looks at unique brands only.



来源:https://stackoverflow.com/questions/54136867/using-countifs-to-count-distinct-values-and-multiple-criteria

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!