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:
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!