I have a worksheet Movements with two fields:
mydate | amount 2009-01-01 | 10.00 2009-01-02 | 13.00 2009-02-01 | 11.00 2009-02-05 | 12.00 2009-02-08 | 52.00
I want to have in another worksheet MonthSum that displays the sums of the data in the column amount grouped by year+month of the column date:
mydate | amount 2009-01 | 23.00 2009-02 | 75.00
I don't want to specify the cells where the spreadsheet has to sum, I want a generic formula to group my data per month+year. If I was on a MySQL database I would simply do:
SELECT DATE_FORMAT('%Y-%m', mydate), SUM(amount) FROM mytable GROUP BY DATE_FORMAT('%Y-%m', mydate)
I need the solution to work on Google Spreadsheets.
I think that possible solutions would be using SUMIF or pivot tables or Google Spreadsheets QUERY function.
Right-Click on any cell within the Dates column and select Group from the fly-out list. Then select Month in the dialog box. Using the Starting at: and Ending at: fields, you can even specify the range of dates that you want to group if you don't want to group the entire list.
This is what pivot tables are for.
I have created an example using your data.
TEXT(A2, "YYYY-MM")
For a quick overview of pivot tables, see this Google blog post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With