Summarize grouping by year and month

后端 未结 6 1912
南笙
南笙 2020-12-24 05:32

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
2         


        
6条回答
  •  庸人自扰
    2020-12-24 05:52

    in addition to contribution from JMax, let me present the following formula using the QUERY function ...

    =query(index('Sheet3'!A:B); "select year(Col1)+(month(Col1)+1)/100,sum(Col2) where Col1 is not null group by year(Col1)+(month(Col1)+1)/100 label year(Col1)+(month(Col1)+1)/100 'mydate',sum(Col2) 'amount' ")
    

    Notes: I have assumed the original data is in Sheet3 and my result presents the year and month combinationas yyyy.mm instead of yyyy-mm I have created an illustration:

提交回复
热议问题