Merge data from duplicate rows in Google Sheets based on a unique column

Merging duplicate rows in your spreadsheets may turn into one of the most intricate tasks. Let's see what Google formulas can help and get to know one smart add-on that does all the job for you.

Functions to combine cells with the same value in Google Sheets

You didn't think Google Sheets would lack functions for this kind of task, did you? ;) Here are the formulas you will need to consolidate rows and remove duplicate cells in spreadsheets.

CONCATENATE – Google Sheets function and operator to join records

The first thing that comes to mind when I think of not simply removing duplicates but bringing duplicate rows together is Google Sheets CONCATENATE function and an ampersand (&) – a special concatenation operator.

Suppose you have a list of movies to watch and you'd like to group them by genre:
Combine rows of movies based on genre.

  • You can merge cells in Google Sheets only with spaces between the values:

    =CONCATENATE(B2," ",C2," ",B8," ",C8)

    =B2&" "&C2&" "&B8&" "&C8
    Combine duplicates using spaces.

  • Or use spaces with any other marks to combine duplicate rows together:

    =CONCATENATE(A3,": ",B3," (",C3,"), ",B6," (",C6,") ")

    =A3&": "&B3&" ("&C3&"), "&B6&" ("&C6&") "
    Make use of the ampersand to separate values.

Once the rows are merged, you can get rid of formulas and keep only the text by the example of this tutorial: Convert formulas to values in Google Sheets

As simple as this way may seem, it is obviously far from ideal. It requires for you to know the exact positions of duplicates, and it's you who should point them out to the formula. So, this can work for small datasets, but what to do when they get bigger?

Merge cells yet keep data with UNIQUE + JOIN

This tandem of formulas finds duplicates in Google Sheets (and merges cells with unique records) for you. However, you are still in charge and have to show the formulas where to look. Let's see how it works on the same to-watch list.

  1. I use Google Sheets UNIQUE in E2 to check genres in column A:

    Get rid of repeats in genres.

    The formula returns the list of all genres no matter if they repeat or don't repeat themselves in the original list. In other words, it removes duplicates from column A.

    Tip. UNIQUE is case-sensitive, so make sure to bring the same records to the same text case. This tutorial will help you do that quickly in bulk.

    Tip. Should you add more values to column A, the formula will expand the list automatically with unique records.

  2. Then I build my next formula with the Google Sheets JOIN function:

    =JOIN(", ",FILTER(B:B,A:A=E2))
    Google Sheets – combine rows with the same value in genre.

    How do the elements of this formula work?

    • FILTER scans column A for all instances of the value in E2. Once located, it pulls corresponding records from column B.
    • JOIN unites these values in one cell with a comma.

    Copy the formula down and you'll get all the titles sorted by genre.

    Note. In case you need years as well, you'll have to create the formula in the neighboring column since JOIN works with one column at a time:

    =JOIN(", ",FILTER(C:C,A:A=E2))
    Bring years for the corresponding movies together.

So, this option equips Google Sheets with a few functions to combine multiple rows into one based on duplicates. And it happens automatically. Well, almost. I intend to hold the perfect solution back to the very end of the article. But feel free to hop to it right away ;)

QUERY function to remove duplicate lines in Google Sheets

There is one more function that helps operate huge tables – QUERY. It may seem a bit tricky at first, but once you learn how to use it, it will become your true companion in spreadsheets.

Here's the QUERY function itself:

=QUERY(data, query, [headers])

How does it work:

  • data (required) – the range of your source table.
  • query (required) – a set of commands to determine conditions in order to get specific data.

    Tip. You can get a full list of all commands here.

  • headers (optional) – the number of header rows in your source table.

To put it simply, Google Sheets QUERY returns some sets of values based on the conditions you specify.

Example 1

I want to get only comic book movies I am yet to watch:

=QUERY(A1:C,"select * where A='Comic Book'")
Google Sheets: use QUERY to remove duplicates.

The formula processes my entire source table (A1:C) and returns all columns (select *) for comic book movies (where A='Comic Book').

Tip. I don't specify the last row of my table (A1:C) intentionally – to keep the formula flexible and return new records in case other rows are added to the table.

As you can see, it works similar to a filter. But on practice, your data can be much bigger – with numbers you may need to calculate.

Tip. Check out other ways to find duplicates in your Google Sheets table in this article.

Example 2

Suppose I'm doing a little research and keeping track of the weekend box office for the newest movies in theaters:
Weekend box office of the latest movies.

I use Google Sheets QUERY to remove duplicates and count the total sum of money earned per movie for all weekends. I also alphabetize them by genre:

=QUERY(B1:D, "select B,C, SUM(D) group by B,C")
Use QUERY to remove duplicates and consolidate rows.

Note. For the group by command, you must enumerate all columns after select, otherwise, the formula won't work.

To sort records by movie instead, I can simply change the order of columns for the group by:

=QUERY(B1:D, "select B,C, SUM(D) group by C,B")

Example 3

Let's assume you successfully run a bookstore and you keep track of all books that are in stock all over your branches. The list goes up to hundreds of books:
Books in store.

  • Due to the hype over the Harry Potter series, you decide to check how many books you have left written by J.K. Rowling:

    =QUERY('Copy of In stock'!A1:D,"select A,B,C,D where A='Rowling'")
    All books written by J.K. Rowling you have available.

  • You decide to go further and keep only the Harry Potter series omitting other tales:

    =QUERY('In stock'!A1:D,"select A,B,C,D where (A='Rowling' and C contains 'Harry Potter')")
    All Harry Potter books you have.

  • Using the Google Sheets QUERY function, you can also count all these books:

    =QUERY('In stock'!A1:D,"select A,B, sum(D) where (A='Rowling' and C contains 'Harry Potter') group by A,B")
    Merge duplicates based on condition and calculate values.

I guess for now you've got an idea of how the QUERY function "removes duplicates" in Google Sheets. Though it's an available-to-all option, for me, it's more like a roundabout way of combining duplicate rows.

Tip. QUERY is so powerful, it can merge not only duplicates within a sheet — it can match & merge the whole tables together.

What's more, until you learn the queries it uses and the rules of applying them, the function won't be much of a help.

The fastest way to combine duplicate rows

When you give up all hope to find a simple solution to combine multiple rows based on duplicates, our add-on for Google Sheets makes a great entrance. :)

Tip. You can read more about this add-on in this article... or look through it below, of course :)

Combine Duplicate Rows scans a column with repeated records, merges corresponding cells from other columns, separates these records with delimiters, and consolidates numbers. All at the same time and in a matter of a few mouse clicks!

Remember my list of books in-store with a few hundred rows? Let's see how the tool will manage it.

Tip. Since the utility is part of Power Tools, please install it first and go directly to the Merge & Combine group:
Merge & Combine group in Power Tools.

Then click the add-on icon to open it:
Combine rows add-on.

  1. Once the add-on is running, select the range where you want to combine duplicate rows:
    Select the range with your data.
  2. Choose those columns that contain repeated values. In my case, they are Last Name and First Name:
    Choose key columns with duplicate records.
  3. The next step lets you decide on the following:
    • columns with values you will bring together
    • ways to combine those records: merge or calculate
    • delimiter to merge cells with the text
    • function to calculate numbers

    For me, I'd like to have all books belonging to one author brought to one cell and separated by break lines. If any titles repeat themselves, the add-on will show them only once.

    As for the quantity, I'm okay with totaling all books per author. The numbers for duplicate titles, if there are any, will be added together.
    Choose columns with the values to merge.

  4. Upon adjusting all settings, click Finish. The add-on will do the work and show the message with everything processed in a few seconds:
    Combine Rows result.

The tool has combined duplicate rows in my list of books. Here's a part of how my data looks now:
Data combined from multiple rows into one row based on column value.

Tip. Alternatively, you can split one sheet to multiple sheets so there's a separate table with all books per author, or highlight duplicate rows in Google Sheets.

Tip. Have a quick look at how I used the add-on:
Combine duplicate rows with the add-on for Google Sheets.

Or watch a short video introducing the tool:

Use scenarios to semi-automate merging duplicates

Another possibility Combine Duplicate Rows offers is to semi-automate its use.

If you often go through the steps and select the same options, you can save them into scenarios. Scenarios let you reuse the same settings effortlessly on the same or different datasets.

You will need to give your scenario a name & specify a sheet and a range it should process:
Save the most often used settings into a scenario.

The settings you save here can be quickly called for from the Google Sheets menu. The add-on will start combining duplicate rows right away, sparing you some extra time:
Save the steps into quickly reusable scenarios.

I truly encourage you to get to know the tool and its options better, for Google Sheets is "dark and full of terrors" if you know what I mean ;)

Table of contents


  1. Thanks so much for these clear tips. The UNIQUE, JOIN and FILTER functions were exactly what I was looking for. Perfect examples and clearly explained.

  2. Thank you. This is going to save me a lot of time.

  3. how to fix marge multiple google sheet data I can't first column data properly my data count 1527 but data I get 801

    Query I write is below:
    =QUERY({'Zahid Jameel'!A2:H;'Haleema Sadia'!A2:H;},"select * where Col1 is not null",0)

    • Hello Yasir,

      For me to be able to help, I need to see your data. Please share an editable copy of your spreadsheet with us directly:
      Make sure your formula is included and specify the expected result.

      Note. We keep that Google account for file sharing only and don't monitor its Inbox. Please do not email there. Once you share the file, just confirm by replying to this reply.

  4. Hello Maam, I have been following your blogs for a couple of months now. I am currently pursuing a course for learning Advanced Excel. I need to submit 1 Task File to my faculty.

    But the file is very tricky. For the past few days, I have tried my best to crack it, but I couldn't.It's actually a bit different from what l had learnt so far. If you could share some mail-id, I can share the file with you on that. Please help me out. I would be very grateful. Thanks.

    • Hello Sonali,

      Please specify if you work in Google Sheets or Excel and describe your task in a few words. I will see if can help and suggest what to do next.

      • Maam, I work on Excel. I have one task file, in which I need to work out some calculations. But unable to do so. It's a bit difficult. Need help on that. I could share the file with you.

        • Sorry, I don't work in Excel and can't help with its tasks. Please find the relevant blog post regarding Excel on our blog. You may find a solution there.

  5. I love this add on. I am use it to merge data coming in from an LMS. Because users are taking several quizzes it is populating a new row for each user for each quiz. Combining the rows based on name is easy and is working well. I am wondering if there is a way to have this auto run each time a new row is added without opening the add on and manually choosing to combine rows. Thanks!

    • Thank you for your feedback, Kelly!

      If it's not too much trouble for you, we would appreciate it if you rate our add-on and share your feedback on Google Workspace Marketplace. It motivates us to provide the best experience for you and helps others understand how our product makes their life easier :)

      As for your feature request, I'm afraid it's currently impossible to process data with this tool automatically. The closest the add-on offers at the moment is the ability to save the settings you use most often into scenarios that you can reuse in a couple of clicks whenever you need.

  6. Hi,

    I've created a google form where members can record the wine they are sending to be stored.
    The form can have up to 6 wines. The responses are recorded in an excel sheet.
    On the same row I would get membership number, name, wine 1, wine 2 and so on

    I've created a sheet where i have used "Data Validation" for a drop down list of the membership number
    once i select the membership number, i automatically have cells using "Match" that fill with name and list of wine stored. The list of wine stored now appear in column because I use "Transpose Data"

    Because the member can fill in the form several times, i end up with various rows with the same membership number, and more different wines

    The issue I have is that when I select the membership number from the drop down, I would only get the wines from the first row identified as matching with the membership wines, but I would not get the other wines.

    Of course an easy way would be to simply filter by membership number but I need to print it out, in a certain layout, without certain data and with additional standard information

    I feel I should follow your tutorial where you can get everything by genre but I'm struggling with the drop down function I'd like to keep.

    Is there a way to do this before I give up something I've spend the day on T_T

    Thank you

    • Hi,

      For me to be able to help you, please share an editable copy of your spreadsheet with us ( with 2 sheets: (1) a copy of your source data (2) the result you expect to get (the result sheet is of great importance and often gives us a better understanding than any text description). I kindly ask you to shorten the tables to 10-20 rows. If you have confidential information there, you can replace it with some irrelevant data, just keep the format.

      To grant us access to your data, press the Share button at the upper right corner of Google Sheets and enter

      Note. We keep that Google account for file sharing only and don't monitor its Inbox. Please do not email there. Once you share the file, just confirm by replying to this comment.

      I'll look into your task and do my best to help.

      • Thank you Natalia, I've just shared the file. Hope this helps clarifying the problem I have.


        • Thank you for the file, Thiky, it helped a lot!

          I put the formula into B8 on the Print Log sheet, please take a look:
          =QUERY({FLATTEN(QUERY({'Form responses 1'!B2:K9},"select Col5, Col6, Col7, Col8, Col9, Col10 where Col1="&$C$5,0))},"select * where Col1 is not null",0)

    • Hello Erin,

      It's quite difficult to offer a certain solution since I don't fully understand how the result should look like. I can only suggest you try the following add-ons:

      • Combine Duplicate Rows if you want to combine data from all rows into one row based on the dates.
      • Split Sheet in case you need to split this table into different tables based on the dates.

      If the tools don't help much, please add to your spreadsheet an example sheet illustrating how your result should look like. I'll see if there's a better solution.

  7. Hi,
    I wanted another solution,
    I wanted to merge the 1st cell and keep the rest of the values as it is

    eg a. 1. ron
    a. 2. ray
    b. 1. ron
    b. 2. ray

    and the output that i want is

    here the a should be combined across 2 rows
    is it possible.

  8. Just had to say thank you for this! Been nagging me for so long how to do this simply, without all the macros, etc. that others online suggest! Beautiful solution.

  9. =QUERY('Copy of In stock'!A1:D,"select A,B,C,D where A='Rowling'")
    *[In the where section I want to matching by A cell link ( where A3 ).
    Is it possible?

    • Hello Rakibur,

      If you need to pull data based on the content of A3, here's the formula:
      =QUERY(A1:G11,"select A,B,C,D where A= '"&A2&"' ")

      A cell reference must be wrapped in ampersands, then double quotes, then single quotes.

Post a comment

Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)