Pivot Tables

Topic 13

Pivot Tables

Learn how to group, aggregate, and calculate statistics using Excel Pivot Tables. We will revisit the StaffData.xlsx spreadsheet from Topic 02 to answer the headcount and salary questions without typing any formulas.

5 concepts Training file: StaffData.xlsx

Download StaffData.xlsx

Step 1 — Data Summarization & The 4 Quadrants

A Pivot Table is an interactive tool that summarizes large datasets in seconds. Instead of writing formulas like COUNTIF or SUMIF, you select data fields and place them into four main areas.

💡
The General Rule of Pivoting
Every summary question has two parts:
1. Summarization / Grouping: The categories we slice by. These go into Rows or Columns.
2. Calculation / Aggregation: The numbers we calculate. These go into Values.

The Excel PivotTable Fields pane contains four drop quadrants (pivot1):

PivotTable Fields Pane

Step 2 — Building Headcount & Total Salary

To find the total salary and staff count by building, we align our fields to the quadrants:
• Group by Building → Drag Building to Rows.
• Count staff → Drag Employee Name (or ID) to Values (Excel defaults to Count for text).
• Sum salaries → Drag Salary to Values (Excel defaults to Sum for numbers).

PivotTable Fields Configuration

This results in the following Pivot Table output (pivot3). Notice that the headcounts and salaries are identical to what we calculated using formulas in Topic 02:

Pivot Table Headcount and Salary Results

Step 3 — Multiple Calculations (Sum, Average, Max, Min)

You can drag a single numeric field to the Values box multiple times. Each instance can be configured to perform a different type of calculation (e.g. Average, Max, Min).

1
Drag the Salary field into the Values area three more times. You will see columns titled Sum of Salary 2, Sum of Salary 3, etc.
2
Right-click any value in the second salary column → Summarize Values By → select Average.
3
Repeat for the remaining columns, selecting Max and Min.

The resulting Pivot Table displays different calculations for the same salary data by building (pivot4):

Multiple calculations (Sum, Average, Max, Min)

Step 4 — Show Values As (% of Grand Total)

Rather than changing the math logic itself, you can change the display type of a values column to represent ratios or percentages.

1
Remove the Average, Max, and Min columns by dragging them out of the Values area.
2
Drag Salary in once more, so you have two identical Sum of Salary columns.
3
Right-click a value in the second column → Show Values As → select % of Grand Total.

This allows you to see both the raw salary sum and the proportion it represents of the company's total payroll (pivot5):

Microsoft Excel — StaffData.xlsx [Pivot Table] Sheet: Summary
A B C
1 Row Labels Sum of Salary Sum of Salary (% of Grand Total)
2 Ain Khaled 3,410,365 9.02%
3 Al Gharrafa 11,568,426 30.59%
4 Doha 10,286,258 27.20%
5 Duhil 6,075,324 16.07%
6 Lusail 3,463,700 9.16%
7 Wakra 3,012,894 7.97%
8 Grand Total 37,816,967 100.00%

Step 5 — Cascading Summaries & Parent Row Ratios

Adding multiple fields to the Rows box creates nested hierarchies (cascading summaries). We can then analyze how subdivisions contribute to their parent categories.

1
Drag the Status field (Full-time vs Part-time) into the Rows area, placing it directly under Building. (pivot6)
2
Drag another Salary field into Values (making three Salary columns total).
3
Right-click a cell in this third column → Show Values As → select % of Parent Row Total. (pivot7)

Dragging the Status field below Building creates a nested layout where you see headcount and salary details segmented by worker type (pivot6):

Nested Hierarchy in Rows

The parent row is the topmost category (Building). The nested rows (Status) will show what percentage of the building's total salary goes to Full-time vs Part-time workers (pivot7):

Cascading Summary and Parent Row Ratios

Self-Check — Verify Your Pivot Table Output

Build the Pivot Table inside StaffData.xlsx as shown above, then input your numbers below to verify they match.

Pivot Table Output Check Input raw numbers only, no commas
Summary Metric Your Value
Ain Khaled Headcount
Lusail Total Salary
Grand Total Headcount (All Buildings)
Grand Total Salary (All Buildings)