Excel Pivot Tables: Practical Exercises
Open the Excel file: Excel Pivot Tables [Link]
Task 1: Sort and filter data
Creating a Table in Excel
Go to the SALES worksheet and convert the dataset to a Table:
1. Click on a cell in the dataset that you want to convert to a table
2. Select Insert > Tables> Table
3. Check the data range includes all the data to be included in the table: A1 through to
E95
4. Check the box next to My table has headers
5. Click OK
Sorting data
First sort the SALES data by Area, to do this:
1. Click any cell in the Area column you want to sort e.g. B4
2. Sort in ascending order by going to the Data > Sort & Filter group> click AZ
Your resulting table should look as follows:
Now sort by Area and Annual Sales. To do this:
3. Click on one of the cells in your dataset
4. On the Data > Sort & Filter group> click Sort and the Sort dialog box appears
5. Select Area from the 'Sort by' drop-down list, if not already selected
6. Click on Add Level and another row appears in the dialog box
7. Select Annual Sales from the 'Then by' drop-down list (it’s the last item)
8. Select Largest to Smallest from the ‘Order’ drop-down list
9. Click OK
1
Filter data
To filter by Region
10. Click the arrow next to Region. Click on Select All to clear all the boxes, and click to check
the box next to East Midlands to filter on this region. [If the filter arrows are not there, put
the cursor in A1, then select Data > Sort & Filter group > Filter. Arrows will appear in the
column headers and you can use the filter as directed at the start of this paragraph].
11. Click OK
12. Click the arrow next to Product. Click on Select All to clear all the boxes, and Check the box
next to Gloves
13. Click OK
To remove the filter go to Data > Sort & Filter group > Clear. To remove the filter and the arrows,
click Filter.
2
Task 2: Create a pivot table
In this exercise you will create and format a pivot table.
The question for this pivot table
What are total sales by store by region?
1. Return to the SALES worksheet.
2. Select any cell in the table
3. Insert > Tables group > PivotTable
4. Click OK to insert the pivot table. The Pivot Tables Fields panel appears on the righthand side.
5. Drag the following fields (Column names, shown in blue in the table below) to the
corresponding areas at the bottom of the Pivot Table Fields panel.
FILTER COLUMNS
ROWS VALUES
Region Annual Sales
Result: Your table will now look like this
6. Now, if we want to look at the sales breakdown across the stores in each Region, we can add
Stores to our Pivot Table as columns.
FILTER COLUMNS
Store
ROWS VALUES
Region Annual Sales
7. Drag the Store field from Columns to Rows, so that it is beneath the Region field, as shown
below:
3
FILTER COLUMNS
ROWS VALUES
Region Annual Sales
Store
Results: your table will now look like this, which is clearer than the previous table:
Change the pivot table’s labels
8. Select the cell showing Sum of Annual Sales and type in a new label: Total Annual Sales
9. Change Row Labels to Regions
10. Change the column width to suit the new labels, if required.
To format the sales data:
1. Click on a cell in the table so that the PivotTables Fields are displayed
2. Click on Total Annual sales (in Values at the bottom right)
3. Select Value Field Settings from the menu
4. Select Number Format from the dialog box, this opens another dialogue box
5. Under Category select Currency
6. Under Negative Numbers select the second option
7. Set Decimal places to 0
8. Click OK
9. Click OK
Note how the table has changed.
10. Now add Products to the columns of your Pivot table.
4
11. Change B3 from Column Labels to Products
Next, we look at how to filter the pivot table.
Filtering pivot tables using the Row and column filtering options
Notice the filtering dropdown control for Product and Region.
12. Click the Product dropdown
13. Select All (to uncheck all)
14. Select Walking Boots then OK. Note the effect on the pivot table data and how the
dropdown icon changes to
15. Undo the filtering by re-selecting Select All or clearing the filter
Using the Filters area in PivotTables
Up to now we have looked at using the Columns, Values and Rows areas. The Filters area is a
powerful option for filtering the entire pivot table. Note that you must have 2 clear rows above the
5
pivot table to make enough room for this to work. Take a moment to think about what the pivot is
showing.
1. Make changes to your SALES pivot table such that:
FILTER COLUMNS
Region Product
ROWS VALUES
Area Annual Sales
Note the addition of a row above the pivot table
2. Click into the filter dropdown (right of ‘All’ in cell B2) and select East Midlands then click OK
3. Notice the effect on the entire pivot then re-filter: click the filter again and choose Select
Multiple Items at bottom
4. Select both East Midlands and Yorkshire (as shown below), click OK
6
Your table should now look like this:
5. Reset to show All Regions
Modifying the Pivot Table summary function
You can change the summary function of your table from SUM to a range of statistical functions.
1. Ensure that your pivot table has the following settings
FILTER COLUMNS
Product
ROWS VALUES
Region Annual Sales
Area
3. Click on Total Annual Sales (in Value)
4. Select Value Field Settings from menu
5. From Summarise Value Field by, Select Average
6. Click OK
7. Your table should now show average product sales value by area and region. Note cell A3
has changed to Average of Annual Sales.
7
Task 3: Creating a Pivot Chart
You can create a Pivot Chart using the data in your pivot table.
1. Return to the last pivot table you created for SALES
FILTER COLUMNS
Product
ROWS VALUES
Region Annual Sales
Area
2. Ensure that your cursor in somewhere in the pivot table. Select PivotTable Tools>
Analyze > PivotChart
3. Select Chart: Column
4. Select Chart type: Stacked column
5. Click OK
6. Add a chart title. PivotChart Tools> Design> Add Chart Element > Chart Title > Above
Chart. Type in a title for your chart.
Note: Region, Area and Product buttons are shown on the Chart with Filter Options
Average Sales by Area and Region
400000
300000
200000
Walking boots
100000
Trousers
0
Jacket
by ster oln am dge ick ugh am ntry ton eds el
d rk
Der e i nc g h r i rw ro g h e p Le ffi Yo Gloves
i c n b o o in v m e e
ds Le sL tti m N rb Co tha hire Sh shi
r
l an ds a nd No d Ca and ete Birm nds or k s i re rk
id l a n id
l
ds l
an Eng nd P nds idla ds N Yo rks
r h Yo
s t M id t M lan ngl f l a l a M n Y o
Ea s t M s d a
Ea t M
i fE to ng id st id
l
Ea s s t o Eas of E st M We t M
Ea Ea st W
e es
Ea W
7. Click the Region filter
8. Click the (Select All) box to deselect all then check the East Midlands box.
9. Click OK. Note how the graph changes
10. Use one of the other filters to create a different view.