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.

PivotTable grouped by month in Excel with Group > Months + Years, showing Aug 2026 at $6,163.75, Sep 2026 at $9,087.75 and Oct 2026 at $7,970.50, and a grand total of $102,763.75.
The finished PivotTable: sales by month inside each year.

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:

SheetWhat it holds
Raw ExportThe export as it arrives: two dates stored as text and one blank date, plus check formulas that find them
SalesThe same 42 invoices, cleaned, with a real date in every row. Build your PivotTable from this sheet.
Pivot CheckFormulas that show exactly what the grouped PivotTable must return, so you can check yours
Free download: Get the PivotTable group-by-month workbook (.xlsx) and follow along. It works in Excel 2010 and later, Microsoft 365 and Excel for the web.

Step 1: Start from clean source data

  1. Put the data in a list with one header per column (Date, Invoice, Customer, Amount) and one invoice per row.
  2. Check that every cell in the Date column is a real date. Real dates are right-aligned by default; text is left-aligned.
  3. 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.
  4. Drag Date to Rows and Amount to Values. Values should read Sum of Amount.
Excel Sales sheet with one row per invoice from Sep 9, 2025: Date, Invoice, Customer and Amount, ready to insert a PivotTable.
Source data: one invoice per row, a real date in every Date cell.
Checkpoint: Excel 2016 and later often group the dates automatically as soon as you drop Date into Rows, showing years, quarters and months. If that happened, right-click a date, choose Group and pick the levels you want in the next step. To stop it, untick the automatic date grouping option under File > Options > Data.

Step 2: Group the dates by Months and Years

  1. Right-click any date in the PivotTable (a row label, not a value) and choose Group.
  2. In the Grouping dialog, Excel fills in the first and last dates. Leave Starting at and Ending at as they are.
  3. Under By, click Months, then Ctrl+click Years so both are selected. Make sure Days is not selected.
  4. Click OK.
Excel PivotTable Grouping dialog starting at 9/1/2025 and ending at 10/31/2026 with Months and Years both selected.
Select Months and Years together.
Days still selected? If Days stays highlighted together with Months, you get one row per day of the month instead of one row per month. Click Months on its own first, then Ctrl+click Years.

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.

Excel PivotTable grouped by Years and Months: 2025 subtotal $27,779.25, Sep 2025 $6,037.75, 2026 subtotal $74,984.50 and a grand total of $102,763.75 on 42 invoices.
Months inside years, with a subtotal per year.
Row labelSum of AmountInvoices
2025$27,779.2512
Sep (2025)$6,037.753
2026$74,984.5030
Sep (2026)$9,087.753
Oct (2026)$7,970.503
Grand Total$102,763.7542
Your PivotTable should match the Pivot Check sheet exactly.

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.

Checkpoint: Your Grand Total is $102,763.75 on 42 invoices, the same as the total on the Sales sheet, and B23 on the Pivot Check sheet shows Ties.

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:

Excel PivotTable grouped by Months only, where Sep shows $15,125.50 because it adds Sep 2025 ($6,037.75) and Sep 2026 ($9,087.75) together.
Months only: September 2025 and September 2026 are added together.
Grouped bySep showsWhy
Months and Years$6,037.75 (2025) and $9,087.75 (2026)Correct: one row per month of each year
Months only$15,125.50Wrong: $6,037.75 + $9,087.75 in one row
This looks right and isn't: The grand total is still $102,763.75, so nothing looks broken. Always add Years when the data covers more than one year, or filter the PivotTable to a single year first.

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.

Excel Cannot group that selection message caused by text dates such as 2025-11-17 and a blank date cell, flagged No by =IF(ISNUMBER(A4),"Yes","No").
Two text dates and one blank date block grouping for the whole field.
Checkpoint: Raw Export J6 shows 2 text dates (rows 11 and 23), J7 shows 1 blank date (row 19), and J8 shows Cannot group.

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.

Excel formula =IF(A11="","MISSING",IF(ISNUMBER(A11),A11,DATEVALUE(TRIM(A11)))) turning the text 2025-11-17 into the real date Nov 17, 2025.
TRIM and DATEVALUE turn text into real dates; the blank needs the invoice.
Ready-to-share test: On the Sales sheet, change the date of INV-5139 in A42 from Sep 28, 2026 to 10/1/2026. On the Pivot Check sheet, Sep 2026 drops to $6,563.50 on 2 invoices, Oct 2026 rises to $10,494.75 on 4, the 2026 subtotal stays at $74,984.50 and B23 still shows Ties. Refresh your PivotTable and it moves the same way. Change A42 back when you are done.

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 seeLikely causeFix
Cannot group that selectionText dates, blanks or errors in the Date columnFind them with ISNUMBER, fix the source and refresh.
Group is greyed outThe PivotTable is in the Data ModelAdd a Month column to the source, or rebuild without the Data Model.
Sep is far too highGrouped by Months only across two yearsSelect Months and Years.
Still one row per dayDays is still selected in the Grouping dialogDeselect Days.
(blank) row in the PivotTableEmpty rows inside the source rangeFill the blank dates, or shrink the source range.
Fix made but still cannot groupThe PivotTable was not refreshedPivotTable 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.

Practice file: Download the PivotTable group-by-month workbook. The “How It Works” sheet lists every formula and what it does.

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.

Discover more from OneXcel Studio

Subscribe now to keep reading and get access to the full archive.

Continue reading