How to Use the COUNTUNIQUE Function in Google Sheets to Find Distinct Values

If you have a massive spreadsheet containing thousands of e-commerce transactions, figuring out your total sales volume is incredibly easy using the standard COUNT function. However, the standard function has a massive blind spot: it counts every single row, regardless of whether the data is repeated.

If your customer “John Smith” bought five different items in five different transactions, the COUNT function will report five customers. If you are trying to calculate your exact number of distinct, individual customers, the standard formula is completely useless. You could use complex Pivot Tables or Advanced Filters to remove duplicates, but Google Sheets has a vastly superior, native solution: the COUNTUNIQUE function.

The Syntax of COUNTUNIQUE

=COUNTUNIQUE(range)

This function does exactly what it says. It mathematically analyzes a massive block of data, instantly discards any duplicate entries it finds in its internal memory, and outputs the final number of distinct, unique values.

Step 1: Identify Your Dataset

Assume you have a sales ledger in Google Sheets. Column A contains the Transaction ID, and Column B contains the Customer Email Address. The data stretches from row 2 all the way down to row 5000.

Step 2: Inject the Formula

  1. Click on any empty cell where you want the final metric to be displayed (e.g., cell E2).
  2. Type the following formula:
    =COUNTUNIQUE(B2:B5000)
  3. Press Enter.

The Result (and Advanced Case-Sensitivity)

The cell will instantly output the exact number of unique human beings who purchased from your store. If there are 4,999 transactions from John, and 1 transaction from Sarah, the output will simply be 2.

Critical Warning: The Case-Sensitivity Trap

The COUNTUNIQUE function is fiercely case-sensitive. It views “[email protected]” and “[email protected]” as two completely different human beings because the capital ‘J’ changes the underlying ASCII value.

If your data is messy because customers typed their emails haphazardly, your unique count will be artificially inflated. To fix this, you must wrap your range in the UPPER or LOWER array function to normalize the text before the counting engine analyzes it.

To execute a flawless, case-insensitive unique count, use this advanced array formula:

=ArrayFormula(COUNTUNIQUE(LOWER(B2:B5000)))

This forces every single email address into lowercase in the background memory before passing it to the unique counter, ensuring absolute mathematical accuracy for your final metric.

RELATED POSTS

  • How to Use the Google Sheets REGEXMATCH Function to Validate Text
  • How to Protect Cells and Ranges in Google Sheets from Accidental Edits
  • How to Use the Google Sheets ISBLANK Function to Clean Data
  • How to Use the UNIQUE Function in Google Sheets to Remove Duplicates
  • How to Use the Google Sheets SPLIT Function to Separate Text
  • Get the best tech tips delivered straight to your inbox.

    Join thousands of readers mastering Apple, Google, Microsoft, and Linux.