How to Merge Duplicate Rows in Google Sheets: Sum the Numbers, Join the Notes and Fill the Blanks (2026)
An order export with the same customer on five rows, a sign-up sheet where people registered twice, a contact list built from three sources: deleting the extra rows is easy, but it throws information away. The second row has the phone number the first one lacks, the third has another order amount, the fourth a note you need. What you usually want is to merge the duplicates: one row per customer, with the amounts added up, the notes joined and the blanks filled in. This guide shows three ways to do that in Google Sheets without touching the original rows, and how to swap the merged rows in afterwards.
The example
A tab called Orders with a header row: Email in A, Name in B, Phone in C, Amount in D and Notes in E.
| Row | A: Email | B: Name | C: Phone | D: Amount | E: Notes |
|---|---|---|---|---|---|
| 2 | ana@x.com | Ana | 40 | Gift wrap | |
| 3 | bo@x.com | Bo | 304-555-0102 | 25 | |
| 4 | Ana@x.com | Ana Ruiz | 304-555-0101 | 15 | Rush |
| 5 | cy@x.com | Cy | 30 | ||
| 6 | ana@x.com␣ | 10 | Gift wrap | ||
| 7 | bo@x.com | Bo | 20 | Invoice sent |
Row 6 has a trailing space after the email (shown as ␣), the kind that comes in from exports and copy-paste. Six rows, three customers, 140 in total. The goal:
| Name | Phone | Orders | Total | Notes | |
|---|---|---|---|---|---|
| ana@x.com | Ana | 304-555-0101 | 3 | 65 | Gift wrap, Rush |
| bo@x.com | Bo | 304-555-0102 | 2 | 45 | Invoice sent |
| cy@x.com | Cy | 1 | 30 |
Why not just use Remove duplicates?
Data › Data cleanup › Remove duplicates deletes rows. Ticking only the Email column, it keeps the first row for each email and removes the rest; Google’s help notes that values that differ only in letter case count as duplicates. After trimming spaces, that leaves three rows here, but the total drops from 140 to 95, Ana’s phone number disappears with row 4, and the notes “Rush” and “Invoice sent” are gone. That is fine when the extra rows are true copies. When they carry different information, merge first.
Step 0: decide what each column should become
- The key (Email): what makes two rows “the same”. Decide whether
Ana@x.comandana@x.comare one customer; for emails they are. - Add up: amounts, quantities, hours.
- Count: how many rows were merged, e.g. number of orders.
- Join: notes, products, tags, listed once each.
- Keep one value: name, phone, address. The formula below takes the first non-blank value, which also fills a blank from another row.
Clean the key first: select column A and choose Data › Data cleanup › Trim whitespace. It removes leading, trailing and repeated spaces, but not non-breaking spaces.
Method 1: a pivot table (no formulas)
- Select the data including the header row (every column needs a header), then choose Insert › Pivot table and create it on a new sheet.
- In the side panel, next to Rows, click Add and choose Email.
- Next to Values, click Add and choose Amount; set Summarize by to SUM if it shows something else. Add Email under Values as well, summarized by COUNTA, for the number of rows per customer.
The pivot table refreshes when the source data changes. It is the quickest way to get totals per key, but it cannot join notes or pick a phone number. If your emails vary in capitalization, add a key column to the Orders tab (header Key in F1, then this in F2) and put Key under Rows instead of Email:
=ARRAYFORMULA(IF(A2:A="", "", LOWER(TRIM(A2:A))))
Method 2: QUERY with group by
One formula on a new tab, with empty cells below and to the right for the result to spill into:
=QUERY(Orders!A1:E, "select lower(A), count(A), sum(D) where A <> '' group by lower(A) label lower(A) 'Email', count(A) 'Orders', sum(D) 'Total'", 1)
| Orders | Total | |
|---|---|---|
| ana@x.com | 3 | 65 |
| bo@x.com | 2 | 45 |
| cy@x.com | 1 | 30 |
group by makes one row for each distinct value and sorts the result by it. lower(A) folds the letter case, which matters because string comparisons in the query language are case-sensitive: the simpler =QUERY(Orders!A1:E, "select A, sum(D) where A <> '' group by A", 1) would give Ana@x.com a row of its own with 15. QUERY does not trim, so run Trim whitespace first; before trimming, the email with the trailing space forms a fourth group. where A <> '' skips the empty rows at the bottom, and the final 1 says the range has one header row. Like the pivot table, QUERY can add up, count, average or take the max or min of a column, but it cannot join text.
Method 3: one formula that merges whole rows
This returns the full merged table from the goal above: the key, the first non-blank name and phone, the number of rows, the total and the distinct notes. Paste it into A2 of a new tab; the line breaks are fine to keep.
=ARRAYFORMULA(LET(k, LOWER(TRIM(Orders!A2:A)), u, UNIQUE(FILTER(k, k<>"")),
HSTACK(u,
MAP(u, LAMBDA(x, IFERROR(INDEX(FILTER(Orders!B2:B, k=x, Orders!B2:B<>""), 1)))),
MAP(u, LAMBDA(x, IFERROR(INDEX(FILTER(Orders!C2:C, k=x, Orders!C2:C<>""), 1)))),
MAP(u, LAMBDA(x, ROWS(FILTER(k, k=x)))),
MAP(u, LAMBDA(x, SUM(FILTER(Orders!D2:D, k=x)))),
MAP(u, LAMBDA(x, IFERROR(TEXTJOIN(", ", TRUE, UNIQUE(FILTER(Orders!E2:E, k=x, Orders!E2:E<>""))))))
)))
How it works:
kis every email lowercased and trimmed, so the three ana rows share one key and you don’t have to clean column A first.uis the list of distinct keys, without blanks, in the order they first appear.- Each
MAP(u, LAMBDA(x, …))produces one column, calculating one value per keyx. HSTACK puts the columns side by side. - First non-blank:
FILTER(Orders!C2:C, k=x, Orders!C2:C<>"")returns that customer’s non-empty phones andINDEX(…, 1)takes the first. Ana’s first row has no phone, so the number comes from row 4. When there is none at all, FILTER returns an error andIFERRORwith no second argument leaves the cell blank, as for Cy. - Count and sum:
ROWS(FILTER(k, k=x))counts the customer’s rows;SUM(FILTER(Orders!D2:D, k=x))adds their amounts. - Join:
UNIQUElists each note once (“Gift wrap” was on two rows) andTEXTJOIN(", ", TRUE, …)joins them, skipping empty cells. UNIQUE is case-sensitive, so “Rush” and “rush” would both be listed.
Add a header row by wrapping the whole thing in VSTACK with the labels first:
=VSTACK({"Email", "Name", "Phone", "Orders", "Total", "Notes"}, ARRAYFORMULA(LET(k, …)))
Replace the … with the rest of the formula above. Every MAP filters the whole tab once per key, which is fine for a few thousand rows; on bigger tabs use fixed ranges such as Orders!A2:A5000 to keep it fast.
Variations
- Latest date per customer: add a column with
MAP(u, LAMBDA(x, MAX(FILTER(Orders!F2:F, k=x))))and format it with Format › Number › Date.MINgives the first date. - Keep the newest name rather than the first: sort the Orders tab newest first, or see remove duplicates but keep the latest row for picking a whole row by date.
- Separate notes with line breaks: use
CHAR(10)instead of", "as the TEXTJOIN delimiter and turn on text wrapping for that column. - Emails that differ in more than case and spaces (Gmail dots, +tags, phone formats): build the key as shown in duplicates that don’t match exactly and use it as
k.
Replace the original rows with the merged ones
- Right-click the Orders tab and choose Duplicate, so you keep an untouched copy.
- Select the merged result, copy it, go to a new tab and use Edit › Paste special › Values only (Ctrl+Shift+V, ⌘+Shift+V on a Mac). The pasted cells are plain values and no longer change.
- Check the totals:
=SUM(Orders!D2:D)and the sum of the merged Total column must be equal (140 here). Also compare the row count with the number of distinct keys. - Work from the new tab. Delete the backup only once you are sure nothing is missing.
Pitfalls
- Numbers stored as text. An amount typed as text, for example pasted with a currency symbol from another system, is not added by SUM, and in QUERY a column’s minority data type is treated as empty. If a total looks low, check that the amount cells are right-aligned numbers.
- Merged cells. A value in cells joined with Format › Merge cells belongs to the top-left cell only, so pivot tables and formulas see the other rows of the merge as empty. Unmerge them with Format › Merge cells › Unmerge and fill the key into every row first.
- Header row inside the range. Start the formula ranges at row 2; QUERY gets the header row through its last argument instead.
- Editing the result. Typing inside a spilled result breaks it with
#REF!. Paste values first if the merged rows need hand edits. - Formatting. Pasting values keeps the numbers, not the formulas; reapply date or currency formats to the new tab if they are lost.
To see how many rows each key has before you merge, see how to count duplicates. To merge lists that live on several tabs, stack them first as in combine lists without duplicates and use the stacked range as the source.
FAQ
How do I combine duplicate rows and add up their values in Google Sheets?
Use QUERY with group by, for example =QUERY(Orders!A1:E, "select lower(A), sum(D) where A <> '' group by lower(A)", 1), or a pivot table with the key column under Rows and the amount column under Values summarized by SUM. Both leave the original rows untouched and return one row per key.
Why doesn’t Data › Data cleanup › Remove duplicates merge the rows?
It deletes rows: it keeps the first row of each group and removes the others, so the amounts and notes on the removed rows are gone. Build the merged rows with a formula first, then replace the original if you need to.
How do I join the text from duplicate rows into one cell?
Use TEXTJOIN over a FILTER of the rows with the same key, wrapped in UNIQUE so each note appears once: =IFERROR(TEXTJOIN(", ", TRUE, UNIQUE(FILTER(Orders!E2:E, k=x, Orders!E2:E<>"")))) inside MAP, as in the full formula in this guide.
How do I fill in blanks from the other duplicate rows?
Take the first non-blank value per key: IFERROR(INDEX(FILTER(Orders!C2:C, k=x, Orders!C2:C<>""), 1)). If one row has the phone number and another doesn’t, the merged row gets the number.
Why does my merged list still show the same email twice?
The two values differ in letter case or a stray space. UNIQUE and QUERY group by compare text exactly. Lowercase and trim the key first, with LOWER(TRIM()) in a formula or lower() in QUERY plus Data › Data cleanup › Trim whitespace on the column.
How do I turn the merged rows into normal values?
Copy the result and use Edit › Paste special › Values only on a new tab. Keep a copy of the original tab until you have checked that the totals match.
Install free from Google Workspace MarketplaceSee SheetDupes
Want to test it first? Try it on sample data (makes a copy of a 12-row example sheet in your Drive).
Related guides
- How to Find and Remove Duplicates in Google Sheets: Highlight, Count, Delete and Keep the Original (2026)
- How to Highlight Duplicates in Google Sheets: Conditional Formatting Formulas for One Column, Whole Rows, Repeats Only and Two Sheets (2026)
- How to Compare Two Columns or Two Sheets in Google Sheets to Find Matches and Duplicates (2026)
- Duplicates That Don’t Match Exactly in Google Sheets: Case, Extra Spaces, Gmail Dots, Phone Formats and Typos (2026)
- How to Remove Duplicates in Google Sheets but Keep the Latest, First or Highest Row per Key (2026)
- How to Prevent Duplicate Entries in Google Sheets: Data Validation Rules, Warnings and a Small Script (2026)
- How to Count Duplicates in Google Sheets: per Value, Extra Rows, Unique Counts and Why the Numbers Disagree (2026)
- How to Combine Two Lists or Several Tabs in Google Sheets Without Duplicates: VSTACK, UNIQUE, One Row per Key and Other Files (2026)
- UNIQUE vs Remove Duplicates in Google Sheets: Live or Static, Letter Case, Spaces, Columns and Headers (2026)
- How to Remove Duplicates Within a Cell in Google Sheets: Comma-Separated Lists, Tags, Line Breaks and Letter Case (2026)
- How to Show Only the Duplicates in Google Sheets: Filter Duplicate Rows, List Repeated Values and Find Rows That Appear Once (2026)
- How to Find Duplicates Across Multiple Columns in Google Sheets: Rows That Match on Two or More Columns, and Values Repeated Anywhere in a Range (2026)
- How to Remove Duplicates Automatically in Google Sheets: Apps Script on a Daily Timer, on Form Submit or From a Menu (2026)
- How to Find Duplicates in Google Sheets but Ignore Blank Cells: Highlight, Count, List and Remove Without Empty Rows Getting in the Way (2026)
- How to Find Duplicate Transactions in Google Sheets: Double-Imported Rows, Invoices Paid Twice and Same-Amount Charges Within a Few Days (2026)
- How to Format Phone Numbers in Google Sheets: Strip Dashes and Spaces, Show (555) 010-1234, Handle +1 and Extensions, Then Find Duplicate Contacts (2026)
- How to Change Text Case in Google Sheets: UPPERCASE, lowercase, Proper Case Names, Sentence Case and Duplicates That Differ Only in Case (2026)
Menu steps follow Google’s Docs Editors Help pages on removing duplicates and trimming whitespace, pivot tables and paste special; query syntax follows the QUERY help page and Google’s Query Language reference (group by, lower(), case sensitivity); function behavior is from the help pages for UNIQUE, FILTER, LET, MAP, LAMBDA, HSTACK, INDEX, IFERROR, TEXTJOIN, SUM and TRIM. Instructions refer to Google Sheets as it worked on November 19, 2026; menu names can change. Google Sheets is a trademark of Google LLC and this site is not affiliated with Google. Questions or corrections: hello@loomwise.app.