How to count unique values based on another column in Excel?
It may be common for us to count unique values in only one column, but, in this article, I will talk about how to count unique values based on another column. For example, I have the following two columns data, now, I need count the unique names in column B based on the content of column A to get the following result:
To solve this problem, the following formula can help you, please do as follows:
1. Enter this formula: =SUMPRODUCT((($A$2:$A$18=D2))/COUNTIFS($A$2:$A$18,$A$2:$A$18&"",$B$2:$B$18,$B$2:$B$18&"")) into a blank cell where you want to put the result, E2, for instance. And then press Ctrl + Shift + Enter keys together to get the correct result, see screenshot:
Note: In the above formula: A2:A18 is the column data that you count the unique values based on, B2:B18 is the column that you want to count the unique values, D2 contains the criteria that you count unique based on.
2. Then drag the fill handle down to get the unique values of the corresponding criteria. See screenshot:
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 8 months agoNevermind it did
- To post as a guest, your comment is unpublished.· 8 months agoDidn't work
- To post as a guest, your comment is unpublished.· 1 years agoThis works great, but what if you need to add a 3rd column of criteria and what if some cells have blanks and you don't want to count the blanks?
- To post as a guest, your comment is unpublished.· 1 years agodid you try COUNTIFS?
- To post as a guest, your comment is unpublished.· 1 years agoHi - this formula worked great for a discrete set of data. When I tried to use it with a dynamic range, it did not function properly. Any idea what's going wrong?
- To post as a guest, your comment is unpublished.· 2 years agoThat worked like a beauty
- To post as a guest, your comment is unpublished.· 2 years agoI can't believe the array formula worked.