Anda di halaman 1dari 8

1 Pivot Tables

A pivot table is a tool that can be used to summarize large amounts of data easily. A pivot table will automatically sort and calculate values based on the data set. The user can change the parameters of a pivot table by dragging or dropping the fields into a graphic display. This is the pivot nature of a pivot table. As the user changes the field references, the table adjusts or pivots to the new parameters. In Figure 9-2, the user can drop the references into rows and columns for the pivot table to display. The data to be shown is placed in the center section. Finally, the data can be Figure 1-2 The Graphic Display of a Pivot Table further refined by placing filters in the top section of the pivot table. Since Pivot tables can have many fields and having so many different fields can be confusing, Excel will list all the fields in a Field List as shown in Figure 9-1. The user can then drop the fields into the graph display shown in Figure 9-2 or place the fields in one of the four box located below the fields list. Each of the four boxes in the Fields List corresponds to one of the four regions in the graphic display. To create a Pivot Table, first select the data for the Pivot Table. Then select the Insert Ribbon, the Tables Group and click Pivot Table. Chose between putting the Pivot Table on a new sheet or an existing sheet it is frequently more convenient to have the Pivot Table on a new worksheet so that the spacing over the pivot table doesnt conflict with the data.

Figure 1-1 Pivot Table Field List

Example Introduction to Pivot Tables

An elementary school teacher has five students. Each student takes English, Math, Science, Art, History and French. Every month the teacher records the grades for each subject in Excel and uses a Pivot Table to calculate averages, high scores, low score and standard deviation. A portion of the teachers grade book is shown in Figure 9-3. Use a pivot table to calculate 1) What student has the highest average score? 2) Who had the highest average score in April? 3) What was the highest score in March (Subject and Student)? 4) What was the standard deviation of the scores in the month of May?
Figure 1-3 A portion of the student grades data



Solution Introduction to Pivot Tables

Create a pivot table by selecting cells $C$4:$F$154 on the Data sheet and place the Pivot Table on a new worksheet. In the Pivot Table Field List on the upper right hand corner of the screen will be four fields. These fields correspond to the four column headers of the data. By checking the box next to a field, that field will be added to the data table. Once a field has been added, it can be dragged to one of the four areas of a Pivot Table: Row Labels, Report Filters, Column Labels and Values. Change Value 1) In order to calculate which student has the highest average Field Settings score, we need to analyze test scores. First add the students field to the Data Table. Check the Students field and add it to the Row Labels section. Since the average score needs to be calculated, place the test scores must be in the values section of the Pivot Table. Check the Score Field and add it to the values section. The default of Excel is to sum the data in the Values section. In order to calculate averages, click on the black triangle on the right of the Score field and select Value Field Settings. Then change Sum to Average. The settings of the Average Test Scores is shown in Figure 9-4. The Pivot table will show Alex with the highest average of 85.667. 2) In order to determine who had the highest average score in April, an additional field must be added to the Pivot Table from Question 1. Using the same Pivot Table, check the Figure 1-4 Fields for Average Test Scores student field and add it to the column labels. The result

shows all the months in the rows and all the students names as the column headers. In the April row, Alex has the highest average with 93.833. 3) Question 3 requires an additional field to be added to the Pivot Table. Keeping the same Pivot

Figure 1-6 Alex has the highest average score in April

Table as Question 2, add the subject field to the Pivot Table. Since the question specifically asks for results in a subset of one of the fields, the Pivot Table will be filtered by this field. Move the Month field to the Report Filter section. Place the Student field in the Colum Lables and in the Subject field Row Labels- it doesnt matter if the Student or Subject field is in the Row or Column section, this will keep the answer consistent with the solution. Then change the Value Field Settings of the Score field to Max. Finally, change the filter to the month of March by clicking on the filter button in the Pivot Table and

Figure 1-5 Pivot Table for the highest score in March.

selecting March. The highest score in the month of March was 100, which was achieved by both Jack and Mary in English. The solution is shown in Figure 9-5. 4) Calculating the Standard Deviation during the month of may requires only small changes to the Pivot Table. First, change the Filter to May instead of March and then change the Value Field Setting to Standard Deviation. Do not be alarmed when errors appear in the individual cells for students and subjects. An error appears because there is only one data point in the cell and a standard deviation cannot be calculated. However, the standard deviation for the class is still

calculated along the border of the Pivot Table. The standard deviation for the month of May was 14.14 points.

Figure 1-7 Standard Deviation in May

Sales Data Pivot Table

An office supply store tracks the sales of its sales representatives in a data table. The company records the date of the sale, the type and quantity sold, the customer and the revenue for the sale. Using a pivot table answer the following questions: 1) 2) 3) 4) 5) 6) 7) What is the total amount sold, in dollars, by each sales representative to each customer? Which sales representative sold the most (in dollars)? Who was the best customer (in dollars)? What item sold the most quantity? Which month was the best for the sales of pens? Which sales representative sold the most pens in the month of January? Which customer bought the most black binders in the month of February?

Figure 1-8 Example of the sales data

Sales Data Pivot Table Solution

First create a pivot table for the sales data on a new sheet. Use the pivot table to solve the above questions. In order to calculate the total amount sold, in dollars, by each sales representative to each customer, the sales data will need to be sorted by the representative and customer fields. Check the Customer and Representative fields and place the fields in the Column label and Row labels respectively. Finally place the Total field in Values and be sure the pivot table is summing the Total field.

Figure 1-9 Solution for question 1

1) Using the solution created above, the sales representative that sold the most was Frank. 2) Using the solution created above, the best customer was Nice Co. 3) To determine the item that sold the most quantity, all the fields will need to be changes. Place the Items field in the Row Labels and place the Date field in the Column labels. Then place the Units field in Values and be sure the pivot table sums the Units. The item that sold the most quantity was binders with 395 units.

Right click to group

Figure 1-10 Solution to question 4

4) In order to determine the best month for pens, the total number of pens in each month will need to be counted. This can be done manually but is frequently an onerous task, particularly with large data sets. It make the task easy, the dates can be group by month to make sorting in the pivot table easier. Right click on any of the dates and then click on group. Excel automatically determines the best grouping category for the data; in this case dates. Click on months and click OK. The result will group all the data by the months: January, February and March. The best month for pens was January with 131 pens sold.

Figure 1-11 Grouping menu

Pivot Charts
A chart is exactly the same as a pivot table, except that the results also include a graph. This can be a useful tool for graphing since results are immediately updated in the graph without manipulating the graphing ranges. Thus the user can make changes to the data sets either by changing the data itself or the parameters and the graphs automatically change according the new parameters.

Pivot Charts Sales Staff

A database company has a sales staff that sells subscriptions to its data base product. The sales staff has three employees: Alan, Eric and Kara. Use a Pivot Chart to graph the total new sales for 2010 against the total new sales for 2011 on a monthly basis.

Solution Pivot Charts Sales Staff

To graph the total new sales for the sales staff use the Sum of the sLegend Field and the Month in the Axis Fields as shown in Figure 9-12. This will graph the Total Sales by Month for each Year.

Hints and Tricks: New Sheet and Titles

Pivot Tables and Pivot Charts are so easy to manipulate it is easy to lose a desired result due to manipulating the data for another reason. For this reason, it is often helpful to create a new sheet for each Pivot function. For example, create a new sheet for Total Sales and another new sheet for any additional analysis. When working with Pivot Charts always add a descriptive title to the chart to describe what the chart represents. Add a title by clicking on the LayOut Ribbon and the Chart Titles Group.

Figure 1-12 Fields for the Pivot Charts Sales Staff Problem

Total Sales for 2010 and 2011

30000 25000 20000 15000 10000 5000 0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
Figure 1-13 Result for the Total New Sales of the data base company

2010 2011