Summarize grouping by year and month

后端 未结 6 1916
南笙
南笙 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:54

    The answer of matt burns and Cœur is pretty accurate and I would like to add a comment (I did not add it on the comment section as it is quite long)

    You may want to use this formula instead: DATE(YEAR(A2);MONTH(A2);1) to group by year & month.

    This way you will keep values as dates and therefore be able to apply any kind of date formatting or sorting in your pivot table.


    Explanation you can skip:

    Instead of TEXT(A2, "YYYY-MM") converts value in text and therefore remove freedom about further date manipulation.

    DATE(YEAR(A2);MONTH(A2);1) remove the day and time from the date so for example 2018/05/03 and 2018/05/06 both become 2018/05/01 which is still a date which can then be grouped together.

    By applying a format "YYYY-MM" directly on the pivot table you reach the same result.

提交回复
热议问题