Dynamic arrays
PIVOTBY
Cross-tab in one formula: rows × columns. In the trainer, one row field and one column field.
Syntax
PIVOTBY(row_fields, col_fields, values, function, …)Example: =PIVOTBY(A2:A20,B2:B20,C2:C20,SUM)
Available in: Microsoft 365 only
Try it
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in F2: =PIVOTBY(A2:A7,B2:B7,C2:C7,SUM)
| A | B | C | D | E | F | G | H | I | J | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Region | Product | Units | Price | Result | |||||
| 2 | East | Pen | 120 | 2.5 | Book | Lamp | Pen | Total | ||
| 3 | West | Pen | 80 | 2.5 | East | 45 | 15 | 120 | 180 | |
| 4 | East | Book | 45 | 12 | North | 60 | 60 | |||
| 5 | North | Book | 60 | 12 | West | 30 | 80 | 110 | ||
| 6 | West | Lamp | 30 | 25 | Total | 105 | 45 | 200 | 350 | |
| 7 | East | Lamp | 15 | 25 |
Result in F2: