Sub topic 2
Group dates by year, month, quarter or weekday
This chapter assumes you can build a pivot table in Google Sheets, that your source data has one header row, and that the date column contains real dates, not text that looks like dates. You should also know how SUM and COUNT summarize values.
Use this sample data in a sheet named Sales, with the headers in row 1:
Date Region Product Units Revenue Cost
2026-01-05 West Widget 10 250 150
2026-01-19 East Widget 4 100 60
2026-02-02 West Gadget 7 420 245
2026-02-23 South Gadget 3 180 105
2026-03-09 East Gizmo 12 600 420Group dates by year, month, quarter or weekday
A pivot date group replaces each individual date with a larger period, such as a month. Insert the pivot table, add Date to Rows, then right-click any date label in the pivot table and choose "Create pivot date group." Select Month, Quarter, Year, or Day of week. Sheets then sums each group's values under one label.
Bucket numbers into intervals
A numeric group rule sorts numbers into ranges. Add Units to Rows, right-click a value, and choose "Create pivot group rule." Set a start, an end, and an interval size, such as 0 to 12 in steps of 5. Each bucket then appears as a row label.
Add a calculated field
A calculated field creates a new column of values from existing source columns. In the pivot table editor, choose Values, then Add, then Calculated field. Enter a name, such as Profit, and a formula.
Write calculated field formulas
Refer to source columns by their exact header names. Start the formula with an equals sign:
=Revenue - CostIf a header contains spaces, wrap it in single quotes:
='Unit Price' * QuantitySheets adds the formula result for each row, then sums the results in each group. This is correct for profit, but not for ratios. For a margin, aggregate first:
=SUM(Profit) / SUM(Revenue)> Note: Do not write the formula =Profit / Revenue for a margin. That divides each row, then sums the results, which gives a wrong total.
Exercise
Q: Using the sample data, what is the Profit for the row dated 2026-02-23?
A: Profit = Revenue - Cost = 180 - 105 = 75.
Estimate
minutes: 25