pivot tables notes

Upload: sashank7

Post on 04-Jun-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/13/2019 Pivot Tables notes

    1/8

    1 Pivot TablesA pivot table is a tool thatcan be used to summarizelarge amounts of dataeasily. A pivot table willautomatically sort andcalculate values based onthe data set. The user canchange the parameters of apivot table by dragging ordropping the fields into agraphic display. This is thepivot nature of a pivottable. As the user changesthe field references, thetable adjusts or pivots tothe new parameters. In

    Figure 9-2, the user candrop the references intorows and columns for thepivot table to display. Thedata to be shown is placedin the center section.Finally, the data can befurther refined by placingfilters 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 inFigure 9-1. The user can then drop the fields into the graph display showninFigure 9-2 or place the fields in one of the four box located below thefields list. Each of the four boxes in the Fields List corresponds to one ofthe four regions in the graphic display.

    To create a Pivot Table, first select the data for the Pivot Table. Then selectthe Insert Ribbon, the Tables Group and click Pivot Table. Chose betweenputting the Pivot Table on a new sheet or an existing sheetit is frequentlymore convenient to have the Pivot Table on a new worksheet so that thespacing over the pivot table doesnt conflict with the data.

    Figure 1-2 The Graphic Display of a Pivot Table

    Figure 1-1 Pivot Table Field List

  • 8/13/2019 Pivot Tables notes

    2/8

    2

    Example Introduction to Pivot Tables

    An elementary school teacher has fivestudents. Each student takes English,Math, Science, Art, History and French.Every month the teacher records thegrades for each subject in Excel and uses

    a Pivot Table to calculate averages, highscores, low score and standard deviation.A portion of the teachers grade book isshown inFigure 9-3. Use a pivot table tocalculate

    1) What student has the highest averagescore?

    2) Who had the highest average score inApril?

    3) What was the highest score in March(Subject and Student)?

    4) What was the standard deviation ofthe scores in the month of May?

    Solution Introduction to Pivot Tables

    Create a pivot table by selecting cells $C$4:$F$154 on the Datasheet and place the Pivot Table on a new worksheet. In the Pivot

    Table Field List on the upper right hand corner of the screen willbe four fields. These fields correspond to the four column headersof the data. By checking the box next to a field, that field will beadded to the data table. Once a field has been added, it can bedragged to one of the four areas of a Pivot Table: Row Labels,Report Filters, Column Labels and Values.

    1) In order to calculate which student has the highest averagescore, we need to analyze test scores. First add the studentsfield to the Data Table. Check the Students field and addit to the Row Labels section. Since the average score needsto be calculated, place the test scores must be in the valuessection of the Pivot Table. Check the Score Field and addit 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 fieldand select Value Field Settings. Then change Sum to

    Average. The settings of the Average Test Scores is showninFigure 9-4. The Pivot table will show Alex with thehighest average of 85.667.

    2) In order to determine who had the highest average score inApril, an additional field must be added to the Pivot Tablefrom Question 1. Using the same Pivot Table, check thestudent field and add it to the column labels. The result

    Figure 1-3 A portion of the student grades data

    Fields

    Data

    Figure 1-4 Fields for Average Test Scores

    Change ValueField Settings

  • 8/13/2019 Pivot Tables notes

    3/8

    3

    shows all the months in the rows and all the students names as the column headers. In the Aprilrow, 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

    Table as Question 2, add the subject field to the Pivot Table. Since the question specifically asksfor 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 ifthe 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 Tableand

    selecting March. The highest score in the month of March was 100, which was achieved by bothJack and Mary in English. The solution is shown inFigure 9-5.

    4) Calculating the Standard Deviation during the month of may requires only small changes to thePivot Table. First, change the Filter to May instead of March and then change the Value FieldSetting to Standard Deviation. Do not be alarmed when errors appear in the individual cells forstudents and subjects. An error appears because there is only one data point in the cell and astandard deviation cannot be calculated. However, the standard deviation for the class is still

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

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

  • 8/13/2019 Pivot Tables notes

    4/8

    4

    calculated along the border of the Pivot Table. The standard deviation for the month of May was14.14 points.

    Figure 1-7 Standard Deviation in May

  • 8/13/2019 Pivot Tables notes

    5/8

    5

    Sales Data Pivot Table

    An office supply store tracks the sales of its sales representatives in a data table. The company records thedate of the sale, the type and quantity sold, the customer and the revenue for the sale. Using a pivot tableanswer the following questions:

    1) What is the total amount sold, in dollars, by each sales representative to each customer?2) Which sales representative sold the most (in dollars)?3) Who was the best customer (in dollars)?4) What item sold the most quantity?5) Which month was the best for the sales of pens?6) Which sales representative sold the most pens in the month of January?7) 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, thesales data will need to be sorted by the representative and customer fields. Check the Customer andRepresentative 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

  • 8/13/2019 Pivot Tables notes

    6/8

    6

    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 Unitsfield in Values and be sure the pivot table sums the Units. The item that sold the most quantity

    was binders with 395 units.

    Figure 1-10 Solution to question 4

    4) In order to determine the best month for pens, thetotal number of pens in each month will need tobe counted. This can be done manually but isfrequently an onerous task, particularly with largedata sets. It make the task easy, the dates can begroup by month to make sorting in the pivot tableeasier. Right click on any of the dates and thenclick on group. Excel automatically determines thebest grouping category for the data; in this casedates. 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.

    Right click to group

    Figure 1-11 Grouping menu

  • 8/13/2019 Pivot Tables notes

    7/8

    7

    Pivot Charts

    A chart is exactly the same as a pivot table, except that the resultsalso include a graph. This can be a useful tool for graphing sinceresults are immediately updated in the graph without manipulatingthe graphing ranges. Thus the user can make changes to the data setseither 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 itsdata base product. The sales staff has three employees: Alan, Ericand Kara. Use a Pivot Chart to graph the total new sales for 2010against 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 thesLegend Field and the Month in the Axis Fields as shown inFigure9-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 tolose 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 newsheet 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 chartrepresents. Add a title by clicking on the LayOut Ribbon and the Chart Titles Group.

    Figure 1-13 Result for the Total New Sales of the data base company

    0

    5000

    10000

    15000

    20000

    25000

    30000

    Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec

    Total Sales for 2010 and 2011

    2010

    2011

    Figure 1-12Fields for the Pivot Charts SalesStaff Problem

  • 8/13/2019 Pivot Tables notes

    8/8

    8