Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use a Google Spreadsheet query to sum rows in another sheet

I have a Google Spreadsheet that spans 3 (work)Sheets. On the first page I have a set of rows with customer data.

That looks like

C      D    E
Joe    -    100
Bob    -    200
Joe    -    300
Jane   -    50

And on sheet 2 I have a column with a formula that attempts to query those values and sum the purchase values for each customer (col E).

The formula I tried to use which fails is:

"=(QUERY('data'!B40:E60, "Select C, Sum(E) where C contains """&A18&""" Pivot C"))

In all seriousness though I really don't care about selecting C this is just the 20th variation I tried. What I am trying to do is sum E for all rows where C matches the cell A18 which is the customer name on sheet 2.

like image 382
Overlordchin Avatar asked Dec 23 '14 16:12

Overlordchin


People also ask

How do I sum cells from different sheets in Google Sheets?

You can use the following basic syntax to sum values across multiple sheets in Google Sheets: =SUM(Sheet1! A1, Sheet2! B5, Sheet3!

Can you query another sheet in Google Sheets?

Here's how it works:Open the Google Sheets document containing the data you want to query. Note down the name of the sheet and the range of cells you want to query. Copy the URL of that document up to the last forward slash. Go back to the document where you want the data to appear.


1 Answers

Try:

=QUERY('data'!B40:E60, "Select C, Sum(E) where C = '"&A18&"' group by C")

and see if that works ?

like image 107
JPV Avatar answered Sep 19 '22 15:09

JPV