How to Group Data by Week in Google Sheets

To group data by week in Google Sheets, you can use a combination of the WEEKNUM and QUERY functions. Here's how:

  1. Organize your data in columns with headers. Make sure you have a date column in your data set.
  2. In a new column, use the WEEKNUM function to find the week number for each date in your date column. For example, if your dates are in column A, starting from row 2, you can use the following formula in cell B2:
=WEEKNUM(A2)
  1. Copy the formula down the entire column B, so you have the week number for each date in your data set.
  2. Create a new sheet by clicking on the "+" icon at the bottom left corner of the Google Sheet.
  3. In the new sheet, use the QUERY function to group your data by the week numbers you calculated in step 2. For example, if your data set is in Sheet1 and you have Week Numbers in column B, you can use the following formula in cell A1 of the new sheet:
=QUERY(Sheet1!A:B, "SELECT A, B, COUNT(A) WHERE A IS NOT NULL GROUP BY A, B ORDER BY A ASC", 1)

This formula will group your data by week number, counting the number of occurrences for each week. Adjust the formula according to your data set and the columns you want to display.

Example

Let's say you have the following data set in Sheet1:

| Date       | Value |
|------------|-------|
| 2021-01-01 | 10    |
| 2021-01-02 | 20    |
| 2021-01-08 | 30    |
| 2021-01-09 | 40    |
| 2021-01-15 | 50    |
| 2021-01-16 | 60    |
  1. Add a new column called "Week Number" in column B and insert the formula =WEEKNUM(A2) in cell B2. Copy this formula down to fill the entire column B.
| Date       | Week Number | Value |
|------------|-------------|-------|
| 2021-01-01 | 53          | 10    |
| 2021-01-02 | 53          | 20    |
| 2021-01-08 | 1           | 30    |
| 2021-01-09 | 1           | 40    |
| 2021-01-15 | 2           | 50    |
| 2021-01-16 | 2           | 60    |
  1. Create a new sheet and insert the following formula in cell A1:
=QUERY(Sheet1!A:C, "SELECT B, SUM(C) WHERE A IS NOT NULL GROUP BY B ORDER BY B ASC", 1)
  1. The result will be a grouped summary of your data by week:
| Week Number | Total Value |
|-------------|------------|
| 53          | 30         |
| 1           | 70         |
| 2           | 110        |
Did you find this useful?