# How to sum by month with QUERY in Google Sheets

Group by month(A)+1: `=QUERY(A1:F13,"select month(A)+1, sum(F) group by month(A)+1 label month(A)+1 'Month', sum(F) 'Revenue'",1)`.

**Google Sheets:** `=QUERY(A1:F13,"select month(A)+1, sum(F) group by month(A)+1 label month(A)+1 'Month', sum(F) 'Revenue'",1)`

**Excel:** Excel has no QUERY function. Sum each month with SUMIFS between its first and last day, or use GROUPBY in Microsoft 365: `=GROUPBY(TEXT(A2:A13,"yyyy-mm"),F2:F13,SUM)`.

## Example

Sample data (row 1 is the header):

| A | B | C | D | E | F |
| --- | --- | --- | --- | --- | --- |
| Date | Rep | Region | Product | Units | Revenue |
| 2026-07-03 | Ana Ruiz | East | Widget | 40 | 2080 |
| 2026-07-06 | Raj Patel | West | Gadget | 25 | 2225 |
| 2026-07-10 | Lee Chen | East | Gizmo | 12 | 1740 |
| 2026-07-14 | Ana Ruiz | North | Gadget | 30 | 2670 |
| 2026-07-17 | Kim Ortiz | West | Widget | 55 | 2860 |
| 2026-07-21 | Raj Patel | East | Widget Pro | 18 | 1422 |
| 2026-07-24 | Lee Chen | South | Gadget | 22 | 1958 |
| 2026-07-29 | Kim Ortiz | East | Gizmo | 9 | 1305 |
| 2026-08-04 | Mo Diaz | North | Gizmo | 14 | 2030 |
| 2026-08-07 | Raj Patel | South | Widget | 20 | 1040 |
| 2026-08-12 | Kim Ortiz | North | Gadget | 16 | 1424 |
| 2026-08-18 | Mo Diaz | East | Gizmo Mini | 28 | 1092 |

Formula in H1: `=QUERY(A1:F13,"select month(A)+1, sum(F) group by month(A)+1 label month(A)+1 'Month', sum(F) 'Revenue'",1)`

Result (spills 3 × 2): Month, Revenue; 7, $16,260; 8, $5,586

## How it works

QUERY's `month()` counts from 0, so January is 0 and July is 6. Adding 1 gives the usual month numbers, and grouping by that expression puts every July order in one row and every August order in another. The label clause must repeat the expression exactly, `month(A)+1`.

## Other ways

- `=QUERY({ARRAYFORMULA(TEXT(A2:A13,"yyyy-mm")),F2:F13},"select Col1, sum(Col2) group by Col1 label Col1 'Month', sum(Col2) 'Revenue'",0)`: Turning each date into year-month text first keeps different years apart and gives readable labels. (Months shown as 2026-07 and 2026-08.)
- `=QUERY(A1:F13,"select year(A), month(A)+1, sum(F) group by year(A), month(A)+1 label year(A) 'Year', month(A)+1 'Month', sum(F) 'Revenue'",1)`: Group by year as well when the data covers more than one year. (An extra Year column.)

## Common mistakes

- Forgetting the +1 labels July as 6.
- month() alone merges the same month of different years. Group by year(A) too, or by yyyy-mm text.
- An open range like A1:F adds a blank group for the empty rows; add `where A is not null`.

## Questions

**How do I show month names instead of numbers?**

Group by text: build `TEXT(A2:A13,"mmm yyyy")` in an array, as in the first alternative, but sort carefully, since text sorts alphabetically.

**How do I sum by week?**

Group by a week number from a helper column, such as `=ARRAYFORMULA(WEEKNUM(A2:A13))`, and query that.

**How do I add a condition, like one region?**

Add a where clause before group by: `select month(A)+1, sum(F) where C = 'East' group by month(A)+1`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/sum-by-month-with-query
