Google Sheets Count Unique Values: Practical Guide
Learn how to count unique values in Google Sheets using COUNTA(UNIQUE(range)) and COUNTUNIQUE. Practical examples, edge cases, and tips for clean, accurate data analysis.

To count unique values in Google Sheets, use either COUNTA(UNIQUE(range)) or COUNTUNIQUE(range). For example, =COUNTA(UNIQUE(A2:A100)) returns the number of distinct non-blank entries in A2:A100, while =COUNTUNIQUE(A2:A100) counts unique values directly. These formulas are essential for data cleaning and creating reliable summaries.
google sheets count unique values: why it matters in data analysis
Mastering how to google sheets count unique values is a foundational skill in data cleaning and analysis. When you work with lists—such as survey responses, inventory, or student scores—you often need to know how many distinct items appear, not how many rows exist. Counting unique values helps you identify duplications, measure variety, and create accurate summaries for dashboards. In this guide, we’ll explore practical, step-by-step methods using built-in functions like UNIQUE, COUNTA, and COUNTUNIQUE. We’ll also cover conditional counting, handling blanks, and multi-column scenarios so you can apply these techniques in real workbooks. According to How To Sheets, robust counting of unique values reduces reporting errors and improves data integrity, which is crucial in professional settings.
=COUNTA(UNIQUE(A2:A100))=COUNTUNIQUE(A2:A100)Overview: The two primary approaches (COUNTA+UNIQUE vs COUNTUNIQUE) both yield the number of distinct, non-blank values, but COUNTUNIQUE is often simpler for clean lists while COUNTA+UNIQUE offers more flexibility for additional filtering steps.
Core formulas: COUNTA, UNIQUE, and COUNTUNIQUE
The core trio for counting unique values in Google Sheets is straightforward. Use UNIQUE to extract the distinct values, then COUNTA to count non-blank results, or COUNTUNIQUE to count distinct values directly. Both approaches have their place depending on whether you also need the list of unique items or additional filtering. In many datasets, combining these functions yields the most reliable counts for downstream analysis.
=UNIQUE(A2:A100)=COUNTA(UNIQUE(A2:A100))=COUNTUNIQUE(A2:A100)Why this matters: If you’re building a summary sheet or a dashboard, choosing the right method affects dynamic updates and performance, especially on large datasets.
Counting with conditions and filters
Often you don’t want all unique values, only those that meet a condition. The FILTER function lets you restrict the range before applying UNIQUE and COUNTA. This is essential for segmenting data (e.g., counting unique responses where a field equals a certain category).
=COUNTA(UNIQUE(FILTER(A2:A100, B2:B100="Yes")))=COUNTUNIQUE(FILTER(A2:A100, B2:B100>0))Notes: FILTER returns only the rows that satisfy the condition, so the subsequent UNIQUE and COUNTA steps count unique values in the filtered subset. This pattern is powerful for conditional reporting and targeted metrics.
Handling blanks, errors, and data types
Blanks and non-text data can skew counts if not handled properly. A common pattern is to filter out blanks before counting unique values, or to use IFERROR to catch unexpected results. You can also apply LEN to skip truly empty cells and ensure numbers are treated consistently with text.
=COUNTA(UNIQUE(FILTER(A2:A100, LEN(A2:A100)>0)))=IFERROR(COUNTA(UNIQUE(A2:A100)), 0)Tip: When your data includes numbers and text, consider normalizing types (e.g., TEXT(value, "0") for numbers) before counting, to avoid treating identical-looking values as different.
Counting across multiple columns with arrays
If your unique values span several columns, you can flatten the range into a single list and then count unique values. Google Sheets provides FLATTEN for this purpose, letting you count unique items across rows and columns in one go.
=COUNTA(UNIQUE(FLATTEN(A2:C100)))=COUNTUNIQUE(FLATTEN(A2:C100))Best practice: Ensure the flattening step isn’t unintentionally introducing separators or artifacts from merged cells; test with representative data before applying to large datasets.
Practical patterns for dashboards and data cleaning
For dashboards, you often need both the list of unique values and their count. A common pattern is to present a small, sorted list of unique items (using SORT with UNIQUE) alongside the total count. You can also create named ranges to reuse the unique list across multiple sheets, ensuring consistency across your workbook. By combining LET with UNQUE and FLATTEN, you can create compact, dynamic counts that auto-update as data changes.
=LET(u, UNIQUE(A2:A100), COUNTA(u))=SORT(UNIQUE(A2:A100))Quality tip: When data structures change, revisit your ranges to avoid hard-coded endpoints that can become stale.
Common pitfalls and tips for accuracy
Be mindful of duplicates that look identical but differ in whitespace, case, or hidden characters. Normalize text where possible (e.g., TRIM, UPPER) before applying UNIQUE. Also, remember that COUNTUNIQUE treats blanks as a special case in some contexts; test with your dataset to confirm behavior. Finally, prefer structured ranges (tables or named ranges) over static A2:A100 references in large workbooks to improve maintainability.
=COUNTA(UNIQUE(TRIM(UPPER(A2:A100))))=COUNTUNIQUE(FILTER(A2:A100, A2:A100<>""))Real-world note: In collaborative sheets, document the method used for counting unique values so teammates understand how counts are derived and can reproduce results.
Steps
Estimated time: 40-60 minutes
- 1
Prepare sample data
Set up a Google Sheet with a few columns, such as A containing values to count and B containing a category or flag. This gives you a tangible dataset to practice on. Include a few blank rows and duplicates to test behavior. ```excel Name,Category Alice,Yes Bob,No Alice,Yes Charlie,Yes Diana,No "",Yes ```
Tip: Create a named range for the data (e.g., DataA) to reuse in multiple formulas. - 2
Count all unique values in one column
Use the basic approach to count unique entries in a single column. This demonstrates the core concept before adding conditions. ```excel =COUNTA(UNIQUE(A2:A100)) ```
Tip: Check for blanks; if blanks exist, COUNTA(UNIQUE(...)) may count them depending on data and locale. - 3
Count unique values with a direct function
If you only need the count of distinct values, COUNTUNIQUE can be simpler and faster for clean lists. ```excel =COUNTUNIQUE(A2:A100) ```
Tip: COUNTUNIQUE may treat blank cells differently across Sheets versions; validate with your data. - 4
Add a condition to your count
Filter the data to count unique values that meet a condition, such as a subset marked Yes. ```excel =COUNTA(UNIQUE(FILTER(A2:A100, B2:B100="Yes"))) ```
Tip: Use FILTER to create a temporary list of qualifying values before unique counting. - 5
Handle blanks and data types
Cleanse the data before counting to avoid skew from blanks or mixed types. ```excel =COUNTA(UNIQUE(FILTER(A2:A100, LEN(A2:A100)>0))) ```
Tip: Combine TRIM and UPPER to normalize values prior to counting if needed. - 6
Count across multiple columns
When values span several columns, flatten the range and count unique results. ```excel =COUNTA(UNIQUE(FLATTEN(A2:C100))) ```
Tip: Be cautious with merged cells; they can distort the flatten step.
Prerequisites
Required
- Required
- A sample dataset in Google Sheets (lists, responses, or inventory)Required
- Basic knowledge of ranges, formulas, and built-in functions (UNIQUE, COUNTA, COUNTUNIQUE)Required
Optional
- Optional: LET, FLATTEN, and FILTER availability in your Sheets versionOptional
- Keyboard shortcuts familiarity for speed (Windows & macOS)Optional
- If you plan to count across multiple columns, ensure consistent data typesOptional
Keyboard Shortcuts
| Action | Shortcut |
|---|---|
| CopyCopy formulas or results | Ctrl+C |
| Paste formulaPaste into a cell | Ctrl+V |
| Fill downApply formula to adjacent cells | Ctrl+D |
| UndoRevert last action | Ctrl+Z |
| RedoReapply last undone action | Ctrl+Y |
| Open FindSearch within the sheet | Ctrl+F |
FAQ
What is the difference between COUNTA(UNIQUE(range)) and COUNTUNIQUE(range)?
COUNTA(UNIQUE(range)) returns the count of distinct non-blank values after extracting unique entries, while COUNTUNIQUE(range) counts unique values directly in the given range. COUNTUNIQUE is simpler for clean lists; COUNTA+UNIQUE is more flexible when you need to inspect the actual unique values.
COUNTA(UNIQUE(range)) counts distinct non-blanks after listing them; COUNTUNIQUE counts distinct values directly in the range.
How can I count unique values with a condition in Google Sheets?
Use FILTER to narrow the range by the condition, then apply UNIQUE and COUNTA or COUNTUNIQUE. Example: COUNTA(UNIQUE(FILTER(A2:A100, B2:B100="Yes"))).
Filter first, then count the unique results to respect the condition.
Do blanks affect the unique count?
Yes, blanks can influence results depending on the method used. Use FILTER with LEN or TRIM to exclude blanks and normalize spacing before counting.
Exclude blanks when counting unique values to avoid skewed results.
Can I count unique values across multiple columns?
Yes. Use FLATTEN to merge the columns into a single list, then count unique values. Example: COUNTA(UNIQUE(FLATTEN(A2:C100))).
Flatten the range and count unique items across columns.
What are best practices for dashboards using unique counts?
Keep a stable, named range for your data, validate with sample data, and document the method used for counting. Consider sorting the unique values for readability.
Stabilize data ranges and document counting method for reliability.
Is there a performance consideration when counting many rows?
Large datasets with many unique values can slow down calculations. Use smaller ranges, efficient filters, and consider aggregating counts in separate summary sheets to improve responsiveness.
Large datasets may be slower; optimize ranges and calculations.
The Essentials
- Count unique values with COUNTA(UNIQUE(range)) for flexibility.
- COUNTUNIQUE(range) offers a concise alternative for clean lists.
- Filter before counting to apply conditions reliably.
- Flatten multi-column data to count across a dataset.
- Test, document, and validate counts in dashboards.