How to Group Data by Month in Google Sheets
Grouping data by month in Google Sheets can be done using a combination of functions like DATE, YEAR, MONTH, and a pivot table. Follow these steps to group your data by month:
- Create a new column in your sheet where you'll calculate the month and year for each date. For example, if your dates are in column A, insert a new column B, and name it "Month-Year."
- In the first cell of the newly created column (cell B2), enter the following formula:
=DATE(YEAR(A2), MONTH(A2), 1)
This formula extracts the year and month from the date in cell A2 and creates a new date with the first day of that month.
- Copy the formula down to all the rows in column B.
- Now you're ready to create a pivot table to group your data by month. Click on any cell within your data range, then go to "Data" > "Pivot table."
- In the Pivot table editor, do the following:a. For "Rows," click "Add" and select the "Month-Year" column.b. For "Values," click "Add" and select the column you want to aggregate (sum, count, average, etc.). Then, choose the aggregation type (SUM, COUNTA, AVERAGE, etc.) from the dropdown menu.c. Optionally, you can add more columns to the "Values" section if you want to aggregate more columns.
- The pivot table will now display your data grouped by month.
Example
Let's say you have a dataset with dates in column A and sales data in column B, and you want to group the sales data by month.
- Insert a new column C and name it "Month-Year."
- In cell C2, enter the formula:
=DATE(YEAR(A2), MONTH(A2), 1)
- Copy the formula down to all the rows in column C.
- Click on any cell within your data range, then go to "Data" > "Pivot table."
- In the Pivot table editor, add the "Month-Year" column to "Rows" and the "Sales" column to "Values." Choose the aggregation type (e.g., SUM, COUNTA, AVERAGE).
- The pivot table will now display the sales data grouped by month.
Did you find this useful?