DATA CLEANUP & ERROR CHECKS
Pivot Table: How to Group Dates by Month (and Fix 'Cannot Group')
Drop a date field into a PivotTable and you get one row per day, which is far too much detail for a monthly report. Grouping turns those days into months in two clicks, but it has two traps: months from different years get added together, and one bad date in the source data makes Excel refuse with "Cannot group that selection." This tutorial covers the grouping, both traps and the fix.

What you will build
Brightline Trading Co. invoices six customers, and the invoicing system exports one row per invoice. The practice file covers 42 invoices from September 2025 to October 2026, so it spans two calendar years on purpose:
| Sheet | What it holds |
|---|---|
| Raw Export | The export as it arrives: two dates stored as text and one blank date, plus check formulas that find them |
| Sales | The same 42 invoices, cleaned, with a real date in every row. Build your PivotTable from this sheet. |
| Pivot Check | Formulas that show exactly what the grouped PivotTable must return, so you can check yours |
Step 1: Start from clean source data
- Put the data in a list with one header per column (Date, Invoice, Customer, Amount) and one invoice per row.
- Check that every cell in the Date column is a real date. Real dates are right-aligned by default; text is left-aligned.
- Click any cell in the list and choose Insert > PivotTable. Keep the suggested range, choose New Worksheet and click OK. Leave "Add this data to the Data Model" unticked.
- Drag Date to Rows and Amount to Values. Values should read Sum of Amount.

Step 2: Group the dates by Months and Years
- Right-click any date in the PivotTable (a row label, not a value) and choose Group.
- In the Grouping dialog, Excel fills in the first and last dates. Leave Starting at and Ending at as they are.
- Under By, click Months, then Ctrl+click Years so both are selected. Make sure Days is not selected.
- Click OK.

Step 3: Read the grouped PivotTable
Years become the outer label, with each month underneath and a subtotal for each year. Excel adds a new Years field to the field list; the original Date field now holds the months.

| Row label | Sum of Amount | Invoices |
|---|---|---|
| 2025 | $27,779.25 | 12 |
| Sep (2025) | $6,037.75 | 3 |
| 2026 | $74,984.50 | 30 |
| Sep (2026) | $9,087.75 | 3 |
| Oct (2026) | $7,970.50 | 3 |
| Grand Total | $102,763.75 | 42 |
The Pivot Check sheet gets the same numbers with SUMIFS between two dates: =SUMIFS(Sales!$D$4:$D$45,Sales!$A$4:$A$45,">="&E5,Sales!$A$4:$A$45,"<="&EOMONTH(E5,0)), where E5 is the first day of the month. A second method that agrees with the PivotTable is the quickest way to trust a report.
Step 4: Avoid the Months-only trap
If you group by Months alone, Excel creates twelve buckets, Jan to Dec, and puts every September in the same bucket regardless of year. With data that spans more than twelve months, that is a silent error:

| Grouped by | Sep shows | Why |
|---|---|---|
| Months and Years | $6,037.75 (2025) and $9,087.75 (2026) | Correct: one row per month of each year |
| Months only | $15,125.50 | Wrong: $6,037.75 + $9,087.75 in one row |
Step 5: Why Excel says 'Cannot group that selection'
Grouping by month only works when every item in the field is a real date. One exception blocks it. The usual causes:
- Dates stored as text, for example 2025-11-17 typed or exported as text, often with a trailing space.
- Blank cells in the Date column, or a source range that runs past the last row of data (whole columns such as A:D include thousands of blanks).
- Error values such as #N/A or #VALUE! in the Date column.
- The PivotTable uses the Data Model (the "Add this data to the Data Model" box was ticked). Group is not available there; add a month column to the source instead (see the FAQ).
- The wrong cell is selected: right-click a date row label, not a value or the grand total.
On the Raw Export sheet, column F tests each date. In F4, copied down:
=IF(ISNUMBER(A4),"Yes","No")
Excel stores a real date as a number, so ISNUMBER returns TRUE for real dates and FALSE for text and blanks. J4:J8 summarize the column with COUNTA, COUNT, =SUMPRODUCT(--ISTEXT(A4:A45)) and COUNTBLANK. You can also find text quickly with Go To Special > Constants > Text, or read how to find inconsistent data types in a column.

Step 6: Fix the dates, refresh and group
Convert the text dates to real dates. In G4, copied down:
=IF(A4="","MISSING",IF(ISNUMBER(A4),A4,DATEVALUE(TRIM(A4))))
TRIM removes the trailing space and DATEVALUE turns text that looks like a date into a real one. Copy column G and use Paste Special > Values over column A, then format it as a date. For a whole column of mixed formats, standardize mixed date formats and remove extra spaces and hidden characters cover the harder cases. A blank date cannot be guessed: look it up on the invoice (INV-5116 is dated Feb 3, 2026) and type it in.
Then go back to the PivotTable and choose PivotTable Analyze > Refresh (Alt+F5). The PivotTable keeps a copy of the source data, so it does not see the fix until you refresh. If the source range was too long, use Change Data Source to cover only the real rows, or turn the data into a Table with Ctrl+T. To refresh every PivotTable in the file at once, see refresh all queries and PivotTables with VBA. Now right-click a date and group again.

That test is also why accountants care about dates: an invoice dated a few days late moves revenue from one month to the next. Month-end cut-off is a classic audit check, and it is exactly what a monthly PivotTable will show you on a monthly profit and loss statement.
Common mistakes and quick fixes
| What you see | Likely cause | Fix |
|---|---|---|
| Cannot group that selection | Text dates, blanks or errors in the Date column | Find them with ISNUMBER, fix the source and refresh. |
| Group is greyed out | The PivotTable is in the Data Model | Add a Month column to the source, or rebuild without the Data Model. |
| Sep is far too high | Grouped by Months only across two years | Select Months and Years. |
| Still one row per day | Days is still selected in the Grouping dialog | Deselect Days. |
| (blank) row in the PivotTable | Empty rows inside the source range | Fill the blank dates, or shrink the source range. |
| Fix made but still cannot group | The PivotTable was not refreshed | PivotTable Analyze > Refresh, then group again. |
Frequently asked questions
How do I group by month and year in a PivotTable?
Right-click a date in the row labels, choose Group, select Months and Years (Ctrl+click), and click OK. Years become the outer label and months sit under each year.
How do I group by week?
In the Grouping dialog, select only Days and set Number of days to 7. Set Starting at to a Monday (or your week start) so the weeks line up.
Can I group by fiscal month or fiscal year?
Not with the Grouping dialog, which uses calendar months. Add a helper column to the source, such as =EOMONTH(A4,-1)+1 for the month start, or a fiscal year formula like =YEAR(A4)+(MONTH(A4)>=7) for a July year start, and put that field in Rows instead.
How do I group dates in a Data Model PivotTable?
Add a helper column to the source data, for example =TEXT(A4,”yyyy-mm”) or =EOMONTH(A4,-1)+1 formatted as mmm yyyy, refresh, and use that column in Rows. This works everywhere, including Power Pivot and Excel for the web.
Why did ungrouping not bring my original dates back?
It does: right-click a grouped label and choose Ungroup. If the Years field stays in the field list, drag it out of the Rows area.
Final checklist
- Every cell in the Date column is a real date (ISNUMBER returns TRUE for all rows).
- No blank rows or error values inside the source range.
- The PivotTable is not in the Data Model, or a month helper column is used instead.
- Months and Years are both selected when the data spans more than twelve months.
- The PivotTable was refreshed after fixing the source.
- The grand total agrees with the source data total.
With dates grouped by month, a PivotTable becomes a quick monthly report. Turn it into a KPI dashboard with a PivotTable, or build the formula version in the sales report dashboard.
Turn raw exports into monthly reports
Browse the OneXcel Tutorial Hub for more step-by-step guides, explore ready-to-use Excel templates, or turn your monthly totals into a dashboard with the OneXcel Dashboard Builder.
