PIVOTBY builds a two-way cross-tab in one formula — rows by one field, columns by another, values aggregated in the middle. A live PivotTable you never have to refresh.
The example
Sales by region (rows) and quarter (columns).
| A | B | C | |
|---|---|---|---|
| 1 | Region | Q1 | Q2 |
| 2 | East | 20,000 | 22,000 |
The formula
Rows, columns, values, aggregation:
How it works
PIVOTBY lays out a full matrix:
- First argument: the row field. Second: the column field.
- Third: the values; fourth: the aggregation (SUM, AVERAGE, COUNT, LAMBDA).
- It spills a complete grid with row and column headers, plus optional totals.
- Like GROUPBY, it recalculates automatically when the data changes — no pivot refresh.
PIVOTBY vs PivotTable: PIVOTBY is live and formula-driven (great for dashboards that must always be current); a real PivotTable offers drag-and-drop, slicers, and drill-down. Use PIVOTBY for always-fresh summaries, a PivotTable for interactive exploration. Pre-2024, build a cross-tab with SUMIFS.
Try it: interactive demo
Region x Quarter cross-tab (fixed sample).
Variations
Counts
Count instead of sum:
Row totals only
Control totals with arguments.
SUMIFS cross-tab
Pre-2024:
Pitfalls & errors
365 (2024+) only. Brand-new; fall back to a SUMIFS matrix where unavailable.
Spill room. The whole grid spills — keep the area below and right clear.
Not interactive. No slicers or drill-down — it’s a formula, not a PivotTable object.
Practice workbook
Frequently asked questions
How do I make a cross-tab with a formula in Excel?
How is PIVOTBY different from a PivotTable?
What's the pre-2024 equivalent?
Stop fighting formulas. Learn them in a day.
This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.
See the Formulas & Functions Class