Google-sheets – Can someone help me with this google sheets group by query

google sheetsgoogle-sheets-query

I have 3 columns. I would like to sum up the total revenue of Revenue by month in Dec-2019 (As you can see there are 2). And also sum up the Net profit by month(As you can see there are 2), last but not least also Net profitability by month.

The formula I've been trying is

=query('Observations Table - Live'!$A$3:$H,"select A, sum(B), group by C")
Metric                      Value              Period

Revenue by month            $1000              Dec-2019
Revenue by month            $2000              Dec-2019
Net profit by month         $500               Dec-2019
Net profit by month         $600               Dec-2019
Net profitability by month  $100               Dec-2019
Net profitability by month  $75                Dec-2019

The outcome I would like to have is this

Period           Revenue by month     Net profit by month   Net profitability by month
Dec-2019         $3000                $1100                 $175

Any help will be very much appreciated.

Best Answer

It looks that you to make some changes to your original formula

Try

=query(A:C,"select C, sum(B) where B is not null group by C pivot A")
  • I'm using A:C instead 'Observations Table - Live'!$A$3:$H because the sample data in the body of the question includes only three columns.
  • Also I'm using where B is not null to filter all the rows where B is blank.

Related

Reference