Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Reverse List in Excel
  • Randomize/ Shuffle List in Excel
  • Conditional Formatting Rules in Excel
  • Subtotal function in Excel
  • How to Create Thermometer Chart in Excel

References

  • Perform case-sensitive Lookup in Excel
  • Merge tables with VLOOKUP in Excel
  • Two-column Lookup in Excel
  • CHOOSE function: Description, Usage, Syntax, Examples and Explanation
  • VLOOKUP function: Description, Usage, Syntax, Examples and Explanation

Data Validations

  • Excel Data validation unique values only
  • Excel Data validation no punctuation
  • Prevent invalid data entering in specific cells
  • Excel Data validation whole percentage only
  • Excel Data validation allow weekday only

Count unique numeric values with criteria in Excel

by

This tutorial shows how to Count unique numeric values with criteria in Excel using the example below;

Formula

{=SUM(--(FREQUENCY(IF(criteria,values),values)>0))}

Explanation

To count unique numeric values in a range with criteria you can use a formula based on the SUM and FREQUENCY functions, together with the IF function to apply criteria.

For example, assume you have a list of employee numbers with hours logged in two different buildings: building A, and building B. You want know how many unique employees logged time in each building. Since the same employee numbers appear more than once in the list, you need a formula that will count unique Employee IDs per building. In the example shown, the formula in G6 is:

{=SUM(--(FREQUENCY(IF(B3:B12="A",C3:C12),C3:C12)>0))}

Note: this is an array formula and must be entered with Control Shift Enter (CSE) syntax

Worked Example:   FREQUENCY function: Description, Usage, Syntax, Examples and Explanation

How this formula works

The FREQUENCY function returns an array of values that correspond to “bins”. In this case, we are supplying a “filtered” set of ids for the data array, and the full set of ids for the bins array. The filtering is done with the IF function here:

IF(B3:B12="A",C3:C12)

Which in the example returns this:

{81400;81405;81405;82364;82364;FALSE;FALSE;FALSE;FALSE;FALSE}

Notice all ids not in building A are FALSE. Next, FREQUENCY returns an array of values that represent a count for each numeric value in the data array. This works because FREQUENCY has a special feature that automatically returns zero for numbers that appear more than once in the data array. The resulting array looks like this:

{1;2;0;2;0;0;0;0;0;0;0}

Next, each of these values is tested to be greater than zero. The result looks like this:

{TRUE;TRUE;FALSE;TRUE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE;FALSE}

Each TRUE in the list represents a unique number in the list, and we just need to add up the TRUE values with SUM. However, SUM won’t add up logical values in an array, so we need to first coerce the values into 1 or zero. This is done with the double-negative (–). The result an array of only 1’s or 0’s.

{1;1;0;1;0;0;0;0;0;0;0}

Finally, SUM adds these values up and returns the total, which in this case is 3.

Worked Example:   Count unique text values in a range in Excel

Multiple criteria

You can extend the formula to handle multiple criteria like this:

{=SUM(--(FREQUENCY(IF((criteria1)*(criteria2),values),values)>0))}

Post navigation

Previous Post:

44 Practical Excel IF function Examples

Next Post:

Large with criteria in Excel

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • Nested IF function example in Excel
  • Extract multiple matches into separate rows in Excel
  • IF, AND, OR and NOT Functions Examples in Excel
  • Complete List of Excel Logical Functions, References and Examples
  • SWITCH function example in Excel

Date Time

  • Get days before a date in Excel
  • Get work hours between dates custom schedule in Excel
  • How to calculate nth day of year in Excel
  • WEEKNUM function: Description, Usage, Syntax, Examples and Explanation
  • MINUTE function: Description, Usage, Syntax, Examples and Explanation

Grouping

  • Map inputs to arbitrary values in Excel
  • Group times into unequal buckets in Excel
  • Calculate conditional mode with criteria in Excel
  • Running count group by n size in Excel
  • Map text to numbers in Excel

General

  • Transpose: Switch ‘Rows to Columns’ or ‘Columns to Rows’ in Excel
  • Basic numeric sort formula in Excel
  • How to password protect excel sheet?
  • How to calculate total from percentage in Excel
  • Flash Fill in Excel
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning