(Excel examples for Beginners)
In this end-to-end excel example, you will learn – Excel formula for Beginners – How to find Unique values by count in Excel.
Excel formula for Beginners – How to Count unique values with criteria in Excel
Generic formula
=COUNTA(UNIQUE(FILTER(range,criteria)))
Summary
To count unique values with one or more conditions, you can use the COUNTA function together with UNIQUE and FILTER. In the example shown, the formula in H7 is:
=COUNTA(UNIQUE(FILTER(B6:B15,C6:C15=H6)))
which returns 3, since there are three unique names in B6:B15 associated with the Omega project.
Explanation
At the core, this formula uses the UNIQUE function to extract unique values and the COUNTA function to count these values. The FILTER function is used to apply criteria.
Working from the inside out, FILTER is used to extract only names that are associated with the Omega project:
FILTER(B6:B15,C6:C15=H6) // Omega names only
This results in an array of results like this:
{"Jim";"Jim";"Carl";"Sue";"Carl"}
Next, the UNIQUE function is used to remove duplicates:
UNIQUE({"Jim";"Jim";"Carl";"Sue";"Carl"})
which results in a new array like this:
{"Jim";"Carl";"Sue"} // after UNIQUE
This array is delivered directly to the COUNTA function, which returns a count of all items in the array:
=COUNTA({"Jim";"Carl";"Sue"}) // returns 3
Unlike the COUNT function, which counts only numbers, COUNTA counts both text and numbers. Since there are three items in array, COUNTA returns 3. This formula is dynamic and will recalculate immediately if source data is changed.
Count unique ignore blanks
Blank cells in the name column can cause the unique count to increase because FILTER will include the empty value in the array delivered to the UNIQUE function. To ignore blank or empty cells in column B, you can adjust the formula above like this:
=COUNTA(UNIQUE(FILTER(B6:B15,(C6:C15=H6)*(B6:B15<>""))))
This is an example of using boolean logic to apply more than one condition. The approach is explained in more detail here.
Count unique with multiple criteria
To count unique values based on multiple criteria, can extend the “include” logic inside FILTER. For example, to count unique names for the Omega project in June only, use:
=COUNTA(UNIQUE(FILTER(B6:B15,(C6:C15=H6)*(D6:D15="june"))))
Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.
Learn by Coding: v-Tutorials on Applied Machine Learning and Data Science for Beginners
Latest end-to-end Learn by Coding Projects (Jupyter Notebooks) in Python and R:
All Notebooks in One Bundle: Data Science Recipes and Examples in Python & R.
End-to-End Python Machine Learning Recipes & Examples.
End-to-End R Machine Learning Recipes & Examples.
Applied Statistics with R for Beginners and Business Professionals
Data Science and Machine Learning Projects in Python: Tabular Data Analytics
Data Science and Machine Learning Projects in R: Tabular Data Analytics
Python Machine Learning & Data Science Recipes: Learn by Coding
R Machine Learning & Data Science Recipes: Learn by Coding
Comparing Different Machine Learning Algorithms in Python for Classification (FREE)
There are 2000+ End-to-End Python & R Notebooks are available to build Professional Portfolio as a Data Scientist and/or Machine Learning Specialist. All Notebooks are only $29.95. We would like to request you to have a look at the website for FREE the end-to-end notebooks, and then decide whether you would like to purchase or not.