PIVOTBY
Cross-tabulate measures using row groups and column groups in a spilling formula.
Syntax
=PIVOTBY(row_fields, col_fields, values, function, [field_headers], [row_total_depth], [row_sort_order], [col_total_depth], [col_sort_order], [filter_array], [relative_to])Worked example
Cross-tabulate the four observations by team and quarter. Both total depths are zero to keep just the four combinations.
=PIVOTBY({"A";"A";"B";"B"},{"Q1";"Q2";"Q1";"Q2"},{5;7;2;3},SUM,0,0,,0)Result Team A has 5 in Q1 and 7 in Q2. Team B has 2 in Q1 and 3 in Q2.
Microsoft documentation
Check the arguments, supported editions and behavior of this function in Microsoft’s reference.
Microsoft referenceThe Excel PIVOTBY Function - Formula Based Pivot Tables
Practice PIVOTBY
Cross-tabulate the four observations by team and quarter. Both total depths are zero to keep just the four combinations.
| A | B | |
|---|---|---|
| 1 | Argument | Input |
| 2 | Row fields | A |
| 3 | A | |
| 4 | B | |
| 5 | B | |
| 6 | Col fields | Q1 |
| 7 | Q2 | |
| 8 | Q1 | |
| 9 | Q2 | |
| 10 | Values | 5 |
| 11 | 7 | |
| 12 | 2 | |
| 13 | 3 | |
| 14 | Field headers | 0 |
| 15 | Row total depth | 0 |
| 16 | Col total depth | 0 |
Show example formula
=PIVOTBY(B2:B5,B6:B9,B10:B13,SUM,B14,B15,,B16) Lesson quiz
Answer three questions to see your level in this lesson.
