Google Sheets Count Unique Values: Step-by-Step Guide
In this article
To count unique values in Google Sheets, use =COUNTUNIQUE(range) for a quick total, or =COUNTA(UNIQUE(range)) if you need the distinct list as well. Both work on desktop and in the mobile app; the formulas are identical, only the way you enter them differs. This guide walks through the exact steps, the common errors that break the count, and how to handle blanks, case differences and multi-column ranges.
What You'll Need
- A Google account with access to Google Sheets (free with any Google account).
- A spreadsheet containing the data you want to analyse, or a blank sheet where you can paste sample data.
- Basic familiarity with typing formulas into a cell and pressing Enter.
Step-by-Step
- Open your spreadsheet. Go to sheets.google.com, sign in, and open the file. On mobile, open the Google Sheets app and tap the file. Menu labels can differ slightly by version, device or region, so if a label below does not match exactly, look for the closest equivalent.
- Pick an empty cell for the result. Click or tap a cell outside your data range, for example
D1, so the formula does not overwrite anything. - Type the COUNTUNIQUE formula. Enter
=COUNTUNIQUE(A2:A100), replacingA2:A100with the actual range that holds your values. Press Enter (or the checkmark on mobile). The cell now shows the number of distinct non-blank values in that range. - Check the result against your data. Scan the column for obvious duplicates. If the number looks too high, you likely have trailing spaces or inconsistent capitalisation, which COUNTUNIQUE treats as different values. See Common Mistakes below.
- Use UNIQUE when you also want the list. In a separate empty cell, type
=UNIQUE(A2:A100)and press Enter. Google Sheets spills the distinct values down the column. To count them, wrap it:=COUNTA(UNIQUE(A2:A100)). This gives the same count as COUNTUNIQUE for most data, but lets you see exactly which values were counted. - Count unique values across multiple columns. If your data sits in two columns (for example first and last names), combine them first:
=COUNTUNIQUE(ARRAYFORMULA(A2:A100&B2:B100)). The ampersand joins each row into a single text string, and COUNTUNIQUE then counts the distinct combinations. Adjust the ranges to match your sheet. - Handle blanks deliberately. COUNTUNIQUE ignores empty cells, so a range with blanks returns only the count of filled values. If you need to include blanks as a value, use
=COUNTUNIQUE(IF(A2:A100="","(blank)",A2:A100))entered as an array formula (press Ctrl+Shift+Enter on desktop, or Cmd+Shift+Enter on Mac). On mobile, the array formula entry works the same way through the formula bar. - Copy the formula down or across if needed. Drag the fill handle (the small square at the bottom-right of the selected cell) to apply the same formula to other ranges. Relative references adjust automatically; use dollar signs (
$A$2:$A$100) if you want the range fixed. - Format the result. Select the cell and use the toolbar to apply number formatting, bold text or a background colour so the count stands out. This is optional but helps when sharing the sheet.
Common Mistakes
- Counting blanks by accident. COUNTUNIQUE skips empty cells, but if your range includes cells with a single space, those count as a value. Clean the data first with
=TRIM(A2:A100)in a helper column, then count that column. - Ignoring case differences. COUNTUNIQUE is case-sensitive: "Apple" and "apple" count as two values. To count case-insensitively, use
=COUNTUNIQUE(ARRAYFORMULA(LOWER(A2:A100))). - Including header rows. If your range starts at row 1 and row 1 is a header like "Name", that header is counted as a unique value. Start the range at row 2 (e.g.,
A2:A100) or exclude it explicitly. - Using COUNTA on the raw range.
=COUNTA(A2:A100)counts all non-blank cells, not unique ones. It is only correct when wrapped around UNIQUE. - Forgetting to lock the range when copying. Without dollar signs, copying the formula down shifts the range and can produce wrong counts or errors.
- Assuming COUNTUNIQUE works in every spreadsheet app. It is a Google Sheets function; Excel uses
=SUMPRODUCT(1/COUNTIF(range,range))or the newer=COUNTA(UNIQUE(range)). If you export to Excel, the formula may not calculate.
Tips
- Use
=COUNTUNIQUE(A2:A100)for a one-cell answer; use=UNIQUE(A2:A100)when you need to inspect the list. - Combine TRIM and LOWER in a helper column to normalise text before counting:
=ARRAYFORMULA(TRIM(LOWER(A2:A100))). - For a quick visual check, apply conditional formatting to highlight duplicates: select the range, then Format > Conditional formatting > Custom formula is, and enter
=COUNTIF(A:A,A1)>1. - Name your ranges (Data > Named ranges) so formulas read clearly, e.g.
=COUNTUNIQUE(CustomerNames). - If you share the sheet, add a note in the cell explaining what the count represents, so others do not overwrite the formula.
Troubleshooting
- The formula returns an error. Check for mismatched parentheses or a missing equals sign. Also confirm the range is valid (e.g.,
A2:A100, notA2-A100). - The count is higher than expected. Look for trailing spaces, non-breaking spaces or mixed case. Use
=TRIM()and=LOWER()in a helper column, then recount. - The count is lower than expected. Your range may be too small. Expand it (e.g.,
A2:A1000) or use an open-ended range likeA2:A(supported in Google Sheets). - UNIQUE spills into cells that already have data. Clear the cells below the formula, or move the formula to a column with empty space. The #REF! error means the spill range is blocked.
- The formula does not update after you edit data. Google Sheets recalculates automatically; if it does not, press Ctrl+R (Cmd+R on Mac) to refresh, or check File > Settings > Calculation for manual recalculation.
- COUNTUNIQUE is not recognised. Make sure you are in Google Sheets, not Excel or another app. If you imported an Excel file, the function may not carry over.
Frequently Asked Questions
What is the difference between COUNTUNIQUE and UNIQUE?
COUNTUNIQUE returns a single number: how many distinct values exist. UNIQUE returns the actual list of distinct values, spilling them into multiple cells. Use COUNTA around UNIQUE if you want both the list and the count.
Does COUNTUNIQUE count blank cells?
No. Empty cells are ignored. Cells containing a space or an empty string returned by a formula are counted as values, so clean your data first.
Can I count unique values across two columns?
Yes. Join the columns with an ampersand inside ARRAYFORMULA, then wrap with COUNTUNIQUE: =COUNTUNIQUE(ARRAYFORMULA(A2:A100&B2:B100)). This counts distinct row combinations.
Is COUNTUNIQUE case-sensitive?
Yes. "Apple" and "apple" are treated as different values. To count case-insensitively, convert the range to lowercase first: =COUNTUNIQUE(ARRAYFORMULA(LOWER(A2:A100))).
Why does my count include the header row?
Because the range starts at row 1. Change the range to start at row 2 (e.g., A2:A100) or exclude the header explicitly.
Does COUNTUNIQUE work in the Google Sheets mobile app?
Yes. The formula is the same; type it into the formula bar and confirm. Array formulas may require using the formula bar rather than direct cell entry.