Group Dates by Month with a Helper Column
You have a long list of dated transactions and want to roll them up by month — but a pivot table or SUMIF needs a month column to group on, and the raw dates are all different days.
Excel & Google Sheets
This formula works in both Excel and Google Sheets.
How it works
TEXT converts the date into a label using a format code — "yyyy-mm" turns 2026-07-21 into "2026-07". Every date in the same month produces the identical label, which is exactly what pivot tables, SUMIF, and COUNTIF need to group on. Putting the year first is the trick: "2026-07" sorts chronologically even though it's text, whereas month names like "Jul" sort alphabetically (Apr, Aug, Dec…). These format codes work identically in Excel and Google Sheets, so the formula travels between platforms without changes.
When to use it
Add this helper column before building a pivot table, a SUMIF-per-month summary, or a monthly chart. Pair it with SUMIF(month column, "2026-07", amounts) for instant monthly totals.
Common mistakes
Did this formula help?
Engine-verified against the sample data aboveLast reviewed 2026-07-08