Sub topic 7
Grouping by Days and Building Weekly Periods
The Grouping dialog has no "Weeks" option. Months, quarters, and years are built in, but weeks are not. You can still get weekly totals in two ways. You can use the Days unit with a seven-day interval, or you can add a week-start column to the source data. This chapter covers both methods and shows how to choose between them.
Prerequisites
This chapter assumes you can do the following:
- Build a PivotTable with a date field in Rows and a Sum or Count in Values.
- Open the Grouping dialog (right-click a date item, then choose Group).
- Know that Excel stores dates as serial numbers, so each day is one whole number. The earlier chapter "Why dates and numbers can be grouped" explains this.
The examples use an Orders table with an Order Date column in A and an Amount column in B. Each row is one order.
Why weeks need a workaround
A week is a run of seven consecutive days. Excel can group by a number of days, and a number of days is just an interval on the serial-number line. Seven days gives a week. The dialog does not know which weekday a week should begin on, so you have to supply that yourself.
Both methods below depend on this. Method 1 places the week boundaries by choosing a start date. Method 2 computes each row's week start in a formula.
Method 1: Group by Days with a seven-day interval
- Put
Order Datein Rows andAmountin Values (Sum). - Right-click any date in the row labels and choose Group.
- In the By list, select Days only. Deselect every other unit.
- The Number of days box becomes available. Set it to
7. - Under Starting at, type the date on which the first week should begin.
- Click OK.
Each row label is now a range such as 1/6/2025 - 1/12/2025. The first date is the start of the period. The second date is the last day it covers.
Why Starting at matters
By default, Starting at holds the earliest date in the data, and every seven-day block is counted from there. If your earliest order is Wednesday 1 January 2025, your weeks run Wednesday to Tuesday. That is rarely what a report needs.
To get Monday-to-Sunday weeks, type a Monday on or before your earliest date. The data begins on Wednesday 1 January 2025, so the Monday before it is 30 December 2024. Type 12/30/2024 (or the equivalent in your regional date format). The first group then covers 30 December to 5 January, even though no orders fall on the 30th or 31st.
You can check the weekday of your start date with a worksheet formula such as =WEEKDAY(DATE(2024,12,30),2). It returns 1 for Monday.
What each setting does
| Setting | Effect |
|---|---|
| Starting at | The first day of the first period. Fixes where every week boundary falls. |
| Ending at | The last date included. Dates after it go into a `>` group. |
| Number of days | The length of each period. Seven gives weeks. Any whole number from 1 upward is accepted. |
The same dialog can make other period lengths. A value of 14 gives fortnights and 28 gives four-week periods. The method is identical; only the interval changes.
Edge cases for Method 1
Days must be the only unit selected. When you select Days together with Months, Quarters, or Years, the Number of days box is disabled and the interval is fixed at 1. You can still group by days within months, but you cannot build weeks that way. This is a design limit of the dialog. A seven-day block can cross a month boundary, so Excel cannot nest such blocks inside months.
Automatic grouping can get in the way. In newer Excel versions, dragging a date field into Rows may already have grouped it by Months, or by Years and Months. If so, the Days option will not behave as you expect. Either ungroup first (right-click, Ungroup) or open the Grouping dialog and deselect the units that are highlighted.
Dates outside the range create extra items. If you type a Starting at date that is later than the earliest date in the data, the earlier rows appear under an item such as <1/6/2025. If Ending at is earlier than the latest date, you will see a > item. These are the rows the settings left out, not errors. Widen the range to remove them.
The last period can be partial. If the data ends on Wednesday, the last group still shows a label covering seven days. Its total covers only the days that have data. This matters when you compare the final week with earlier full weeks.
Text dates still block grouping. If any cell in the date column is text or blank, Excel reports "Cannot group that selection". Check a cell with this formula:
=ISNUMBER(A2)It returns TRUE for a real date and FALSE for text. A later chapter covers fixing this error in full.
Method 2: A week-start helper column
The Days method is quick, but it has limits. The labels are range strings rather than dates, so you cannot sort or filter by date value as easily. You also cannot combine weeks with other date units. A helper column avoids these limits by storing the week's start date in the source data itself.
Add a column to the right of Amount, call it Week Start, and enter this formula in the first data row:
=A2-WEEKDAY(A2,2)+1WEEKDAY(A2,2) returns 1 for Monday through 7 for Sunday. Subtracting it moves the date back to the previous Sunday, and adding 1 moves it forward to Monday. Format the column as a date, for example yyyy-mm-dd.
| Order Date | Weekday | WEEKDAY(…,2) | Week Start |
|---|---|---|---|
| 2025-01-01 | Wednesday | 3 | 2024-12-30 |
| 2025-01-06 | Monday | 1 | 2025-01-06 |
| 2025-01-08 | Wednesday | 3 | 2025-01-06 |
| 2025-01-12 | Sunday | 7 | 2025-01-06 |
| 2025-01-13 | Monday | 1 | 2025-01-13 |
All dates from Monday 6 January to Sunday 12 January share the value 2025-01-06. When you put Week Start in Rows, the PivotTable creates one row per distinct value. Each row is a week, with no Grouping dialog involved.
Variants
If your reports label weeks by their last day, use a week-ending formula. This one gives the Sunday that closes each week:
=A2+7-WEEKDAY(A2,2)Check it against the table: for 2025-01-08, the result is 8 + 7 − 3 = 12, which is Sunday 12 January.
For Sunday-start weeks, change the second argument of WEEKDAY to 1. In that mode Sunday is 1 and Saturday is 7:
=A2-WEEKDAY(A2,1)+1A benefit of the helper column
Because Week Start holds real dates, you can still group it. You can add a Months or Quarters grouping to the Week Start field. Each week is assigned to the month in which its start date falls, so a week that begins on 30 December is counted in December. This is useful for rollups, but note that a week spanning two months is not split between them. If you need exact month totals, group the original Order Date field instead.
Choosing between the methods
| Consideration | Days with 7 | Helper column |
|---|---|---|
| Needs source edits | No | Yes |
| Weekday start | Set by Starting at | Set by formula |
| Labels | Text ranges | Real dates |
| Combine with months or years | No | Yes, by grouping the helper field |
| Shared source with other PivotTables | Grouping is per PivotTable cache | Column is available to all |
| Works for read-only or external data | Yes | Only if you can add columns |
Use Days with 7 for a fast exploratory view. Use a helper column when the report will be reused, when other people refresh it, or when the week definition must be exact and visible in the data.
Behavior after data changes
Groups made with the Days method are tied to the settings you typed. When new rows arrive and you refresh, rows dated within Starting at and Ending at fall into the correct week. Rows outside that range appear in the < or > items. If you want the new data to join weeks automatically, reopen the Grouping dialog and extend Ending at.
A helper column recalculates for new rows when the source is a Table, because the formula fills down. Every new date gets a week start, and new weeks simply appear as new rows. The final chapter in this tutorial covers refresh behavior in more detail.
Exercise
Your orders start on Thursday 2 January 2025. You group Order Date by Days with Number of days = 7 and leave Starting at on its default. The report needs Monday-to-Sunday weeks. What date do you type in Starting at, and why?
Show answer
Type Monday 30 December 2024. By default the first period starts on the earliest date (Thursday 2 January), so every week would run Thursday to Wednesday. Starting on the Monday before the earliest date makes each block of seven days run Monday to Sunday. Note that 2025-01-01 is a Wednesday, so 30 December 2024 is the Monday of the week that contains it.
Exercise
A date in A2 is Saturday 11 January 2025. What do =A2-WEEKDAY(A2,2)+1 and =A2+7-WEEKDAY(A2,2) return?
Show answer
WEEKDAY(A2,2) is 6 for Saturday. The first formula gives 11 − 6 + 1 = 6, so Monday 6 January 2025 (the week start). The second gives 11 + 7 − 6 = 12, so Sunday 12 January 2025 (the week end).
Exercise
You open the Grouping dialog and the Number of days box is greyed out. Name the most likely cause and the fix.
Show answer
Another unit, such as Months or Years, is selected along with Days. This can happen when Excel grouped the field automatically. Deselect every unit except Days, and the Number of days box becomes available. If the dialog still resists, right-click and choose Ungroup first, then group again.
Exercise
Why might you choose a Week Start helper column over the Days grouping for a monthly management report that also needs a month rollup?
Show answer
The Days method cannot be combined with Months, because Number of days is disabled when any other unit is selected. A helper column holds real dates, so you can group its field by Months and Years as well. Each week is counted in the month of its start date, so a week that spans two months is not split.