1

I have in my Google Spreadsheet two separate tabs containing each one a table as showed hereafter:

Tab 1                                 Tab 2
______________________________         _________________________
|Client   |Date         |Sum  |       |Client| Date       |  Sum|
|------------------------------        --------------------------
|Dan      | 27/07/2014  | 5   |       |Sam   | 12/07/2014 | 6   |
|Sam      | 02/07/2014  | 5   |       |Nat   | 12/07/2014 | 6   |
|Alex     | 13/07/2014  | 2   |       |Tom   | 13/07/2014 | 3   |
|Tom      | 13/07/2014  | 10  |       |Dan   | 27/07/2014 | 2   |
-------------------------------        -------------------------|

I would like to get to merge these 2 tables and get rid of doublets by putting all the rows containing the same "Date" and "Client" couple and adding the values of the "Sum" field. Here is what I would like to get:

Client     Date          Sum
Dan        27/07/2014    7
Sam        02/07/2014    5
Sam        12/07/2014    6
Alex       13/07/2014    2
Nat        12/07/2014    6
Tom        13/07/2014    13

As you can see, here I just merged those 2 tables and eliminated the doublets

 1) "Dan"&"27/07/2014" the sum of their "Sum" values making "7"
 2) "Tom"&"13/07/2014, the sum of their "Sum" values making "13"

How can I get it using Query function? Can anyone help me?

5

You can implement array concatenation using curly braces:

=QUERY({'Tab 1'!A:C;'Tab 2'!A2:C},"select Col1, Col2, sum(Col3) where Col1 != '' group by Col1, Col2 label sum(Col3) 'Sum'",1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.