To sum unique values in Google Sheets, use =SUMPRODUCT(COUNTIF(A2:A10,A2:A10)=1,A2:A10) to sum values that appear only once, or =SUMPRODUCT(1/COUNTIF(A2:A10,A2:A10),A2:A10) to sum each distinct value once, even if it repeats. For a list of unique values you can then sum, use =UNIQUE(A2:A10) and wrap it with SUM.
Understanding “Unique” vs. “Distinct”
Before choosing a formula, know the difference. In spreadsheet language, unique means values that occur only once in the range. Distinct means each different value, regardless of how many times it repeats. For example, in the list 5, 5, 7, 9, the unique values are 7 and 9 (sum 16), while the distinct values are 5, 7, 9 (sum 21). Most people asking “sum unique values” actually want the distinct sum, but the exact wording matters for the formula you use.
Method 1: Sum Distinct Values with SUMPRODUCT
This is the classic approach that works in both Google Sheets and Excel. It sums each distinct value exactly once.
Assume your numbers are in A2:A10. Enter:
=SUMPRODUCT(1/COUNTIF(A2:A10,A2:A10),A2:A10)
How it works: COUNTIF counts how many times each cell’s value appears in the range. Dividing 1 by that count gives a fraction (e.g., if a value appears 3 times, each occurrence gets 1/3). SUMPRODUCT multiplies each fraction by the value and adds them, so a value appearing 3 times contributes 3 × (1/3 × value) = value. The result is the sum of distinct values.
Example: If A2:A10 contains 10, 20, 10, 30, 20, 40, the formula returns 100 (10+20+30+40).
Method 2: Sum Only Values That Appear Once
If you literally want to sum values that appear only once, use COUNTIF to test for a count of 1.
=SUMPRODUCT((COUNTIF(A2:A10,A2:A10)=1)*A2:A10)
This multiplies each value by TRUE (1) if its count is 1, and FALSE (0) otherwise. In the same example, values 30 and 40 appear once, so the result is 70.
Method 3: Using UNIQUE and SUM (Easier to Read)
Google Sheets has a dedicated UNIQUE function (Excel 365 also has it). To get a list of distinct values, enter in a cell:
=UNIQUE(A2:A10)
This spills the distinct values down. Then sum that spilled range with:
=SUM(UNIQUE(A2:A10))
This returns the same distinct sum as Method 1. For unique-only (appear once), combine UNIQUE with COUNTIF:
=SUM(UNIQUE(A2:A10, , TRUE))
The third argument TRUE in UNIQUE tells it to return only values that appear exactly once. So this sums only the once-occurring values.
Handling Text and Blank Cells
All formulas above work with text as well as numbers, but blanks can cause issues. COUNTIF counts blank cells, which can distort the fraction method. To ignore blanks, use FILTER first:
=SUMPRODUCT(1/COUNTIF(FILTER(A2:A10,A2:A10<>""),FILTER(A2:A10,A2:A10<>"")),FILTER(A2:A10,A2:A10<>""))
For the UNIQUE method, blanks are automatically ignored because UNIQUE excludes empty cells by default. For text, the sum of distinct text values will be 0 because text is treated as 0 in arithmetic, but the UNIQUE list still shows them. If you need to count text, use COUNTA(UNIQUE(...)) instead of SUM.
Common Problems and Solutions
- #DIV/0! error in the fraction method: This happens when there are blank cells in the range because
COUNTIFcounts them, making the denominator 0. Fix by usingFILTERas shown above, or ensure the range has no blanks. - Wrong sum for text values: SUM ignores text, so if your range contains text, the sum will be 0. Use
COUNTA(UNIQUE(range))to count distinct text entries. - Formulas not updating: If you change data and the formula doesn’t recalculate, press Ctrl+R (Windows) or Cmd+R (Mac) to refresh. Google Sheets usually recalculates automatically, but large sheets can lag.
- UNIQUE not available?
UNIQUEis available in all current Google Sheets. In Excel, it requires Excel 365 or Excel 2021. If you’re on an older Excel, use the SUMPRODUCT method.
Comparing Google Sheets and Excel
The SUMPRODUCT methods work identically in both Google Sheets and Microsoft Excel (all versions). The UNIQUE function exists in Excel 365 and Excel 2021, but not in Excel 2019 or earlier. In Google Sheets, UNIQUE is available to all users. Also, in Excel you must press Ctrl+Shift+Enter for array formulas in older versions, but Google Sheets handles them automatically. For Mac Excel, keyboard shortcuts use Cmd instead of Ctrl.
Frequently Asked Questions
How do I sum unique values with multiple criteria?
Use UNIQUE with FILTER. For example, to sum distinct sales amounts where region is “West”, with sales in B2:B10 and region in C2:C10, use: =SUM(UNIQUE(FILTER(B2:B10, C2:C10="West"))). This filters the range first, then finds distinct values and sums them.
Why does my formula return 0 for text values?
Because SUM adds numbers only. If you need to count distinct text entries, use =COUNTA(UNIQUE(A2:A10)). To sum numbers that are stored as text, convert them with VALUE() first, e.g., =SUM(UNIQUE(VALUE(A2:A10))).
Can I sum unique values in a pivot table?
Yes. In Google Sheets, create a pivot table, add your value field, then set “Summarize by” to “SUM”. To get distinct values, you’d need to add a helper column with =UNIQUE and pivot that, or use a calculated field—but it’s simpler to use the formulas above.
What if my data has duplicates and I want to sum each duplicate once?
That’s exactly the distinct sum. Use =SUM(UNIQUE(A2:A10)) or the SUMPRODUCT fraction formula. Both give the same result.
Does the order of values matter?
No. The formulas work regardless of order. UNIQUE returns values in the order they first appear, but the sum is the same.
Can I use these formulas in Excel for the web?
Yes, Excel for the web supports UNIQUE and SUMPRODUCT. The keyboard shortcuts differ slightly, but the formulas work the same.
Related
- Balance Sheet vs Income Statement: Key Differences
- Voter Registration Data Entry Jobs: Real Work & Pay
- ERF.PRECISE in Google Sheets: Function Guide
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Compare Documents in Word: See Every ChangeTo compare two versions of a document in Microsoft Word, open Word and choose Review > Compare >…
- Excel Solver: How to Add an Objective CellTo add an objective in Excel Solver, open Data > Solver, enter the single cell you want to…
- Lock Cells in Excel for the Web: A Step-by-Step GuideTo lock cells in Excel for the web, leave the cells you want protected marked as locked, unlock…
- How to Align Checkboxes in Excel: Step-by-StepTo align checkboxes in Excel, first identify whether they are in-cell checkboxes or floating objects. For in-cell checkboxes,…
- Merge in Excel Without Merging: Center Across SelectionTo make a heading appear centered across several Excel columns without combining the cells, select the range, open…
- How to Find Hidden Tabs in ExcelTo find a hidden worksheet in Excel for Microsoft 365 on Windows, right-click any visible sheet tab, choose…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.