hit 101 3 excel pivot tables - slides
DESCRIPTION
This is a presentation which is used in Healthcare IT Professional (HITP) course.The goal is to show the student how data can be organized and manipulated (drill down, slice and dice..) using Excel.This part comes after introduction to data warehouse and OLAP.www.alamedaservices.comTRANSCRIPT
AlamedaServices.com
1
Healthcare IT Professional
HIT 101-3 Using Excel for Data Management (Pivot Tables)
AlamedaServices.com
2
A Pivot Table is the name Excel gives to what is more commonly known as a cross‐tabulation table. Such tables can be one, two or three‐dimensional and offer a range of summary statistics. They can be modified interactively and can be based on data from more than one worksheet.
Pivot Table Introduction
AlamedaServices.com
3
• To summarize the data contained in a lengthy list into a compact format
• To find relationships within the data that are otherwise hard to see because of the amount of detail
• To organize the data into a format that’s easy to chart
Three key reasons for
organizing data into a Pivot Table are:
Why organize list data into a Pivot Table?
AlamedaServices.com
4
PRODUCT REGION SALES_REVENUEHard Drive East 20,000.00$ Hard Drive West 10,000.00$ Hard Drive South 12,000.00$ Hard Drive North 40,000.00$ Printer East 109,000.00$ Printer West 12,100.00$ Printer South 120,800.00$ Printer North 120,800.00$ Zip Drive East 14,000.00$ Zip Drive West 22,600.00$ Zip Drive South 27,800.00$ Zip Drive North 13,900.00$ 56K Modem East 13,500.00$ 56K Modem West 24,800.00$ 56K Modem South 21,000.00$ 56K Modem North 32,400.00$
The spreadsheet illustration above is a simple Excel list. Even looking at this simple, short list it’s difficult to discern patterns in the data.
For example, it takes a bit of study to see that the number of Units Sold in the North region is much greater than the number of Units Sold for any other regions. Or to find out that PRINTER is the most popular item in all regions.
AlamedaServices.com
5
By contrast, the Pivot Table above simplifies and summarizes the data to make relationships and patterns obvious. And, if you had much more data in the list at left (perhaps with many additional entries for each region), you could still achieve a condensed Pivot Table summary the same size as the one at right. The Pivot Table also allows you to include or exclude whatever list data you like.
Sum of SALES_REVENUE PRODUCTREGION 56K Modem Hard Drive Printer Zip Drive Grand TotalNorth 32400 40000 120800 13900 207100South 21000 12000 120800 27800 181600Grand Total 53400 52000 241600 41700 388700
Sum of SALES_REVENUE PRODUCTREGION 56K Modem Hard Drive Grand TotalEast 13500 20000 33500North 32400 40000 72400South 21000 12000 33000West 24800 10000 34800Grand Total 91700 82000 173700
Sum of SALES_REVENUE PRODUCTREGION 56K Modem Hard Drive Printer Zip Drive Grand TotalEast 13500 20000 109000 14000 156500North 32400 40000 120800 13900 207100South 21000 12000 120800 27800 181600West 24800 10000 12100 22600 69500Grand Total 91700 82000 362700 78300 614700
Two Regions
Two Products
AlamedaServices.com
6
You can easily chart the data organized into a Pivot Table, while to chart the data in the list first need to restructure the data and obtain the sum for each region. The Pivot Table simplifies the process because it obtains subtotals automatically and puts them in a range you can immediately use for charting.
0
20000
40000
60000
80000
100000
120000
140000
East North South West
56K Modem
Hard Drive
Printer
Zip Drive
Drop Page Fields Here
Sum of SALES_REVENUE
REGION
PRODUCT
AlamedaServices.com
7
• a data field, where the data field is the variable you want to summarize
• a row and/or column field where the row and/or column fields are the variables that will “control” the data summary
To create a Pivot Table you need to identify these two elements in your data:
What’s Required to Construct a Pivot Table?
AlamedaServices.com
8
• Allows you to specify where your data is located and whether you want a chart as well as a table.
• Most commonly you’ll get your data from an Excel list that’s part of the current worksheet.
Step 1:
To create the Pivot Table, invoke the Pivot Table Wizard with the menu commands Data, Pivot Table and Pivot Chart Report. The Pivot Table Wizard leads you through three steps:
AlamedaServices.com
9
• Identifies the list range.• If you have the insertion point anywhere in the list when you start the Wizard, Excel defines the list range automatically.
Step 2:
AlamedaServices.com
10
• Creates the Pivot Table using its best guess as to layout.Step 3:
Use This
AlamedaServices.com
11
If you choose the Layout button in Step 3 or invoke that view while working with the Pivot Table, you get a dialog that looks like this:
AlamedaServices.com
12
Drag field buttons at right (representing variables from the list) to the layout diagram at left.
AlamedaServices.com
13
Once you’ve created your Pivot Table, you can modify it by using the buttons on the Pivot Table toolbar that automatically displays.
AlamedaServices.com
14
•A row field in a Pivot Table is a variable that takes on different values. For example, a row field might be “Manufacturer” and its values might be “Desire”, “Marco Polo Jeans”, “New Fashion”, “Vector” and “Young Look”.
• The values a variable takes on are sometimes referred to as “items”.
A row field
Sum of Monthly SalesManufacturer TotalDesire 120000Marco Polo Jeans 78000New Fashion 15000Vector 30000Young Look 48000Grand Total 291000
In the example below, for each value of the variable “Manufacturer”, the Pivot Table displays a summary of the chosen data field in an adjoining column. The data field in this example is “Annual Sales” and the summary function is sum.
Notice that the Pivot Table uses the label “Sum of Annual Sales” to identify not only the data field (Annual Sales) but also the default summary operation (sum).
Pivot Table Row and Column Fields
AlamedaServices.com
15
•A Pivot Table column field works like a row field. A column field might be the variable “Year” with values ranging from 1999 to 2001. Data beneath each column in the Pivot Table is associated with the year at the head of the column.
A column field
Manufacturer Year Annual Sales Sum of Annual Sales YearVector 1999 $220,000 Manufacturer 1999 2000 2001 Grand TotalNew Fashion 1999 $108,000 Desire $456,000 $460,000 $410,000 $1,326,000Young Look 1999 $300,000 Marco Polo Jeans $234,000 $280,000 $360,000 $874,000Desire 1999 $456,000 New Fashion $108,000 $100,000 $120,000 $328,000Marco Polo Jeans 1999 $234,000 Vector $220,000 $230,000 $200,000 $650,000Vector 2000 $230,000 Young Look $300,000 $302,000 $320,000 $922,000New Fashion 2000 $100,000 Grand Total $1,318,000 $1,372,000 $1,410,000 $4,100,000Young Look 2000 $302,000Desire 2000 $460,000Marco Polo Jeans 2000 $280,000Vector 2001 $200,000New Fashion 2001 $120,000Young Look 2001 $320,000Desire 2001 $410,000Marco Polo Jeans 2001 $360,000
AlamedaServices.com
16
When you define a Pivot Table you must identify a data field, or the variable to summarize otherwise Excel displays an error. By contrast, however, you need not define either a row or a column field. In this case, you won’t get an error message but you won’t get a very meaningful result either. Without a row and/or column “control”, Excel will return a simple table since it will have no way to summarize the data.
If you specify a row field only, your Pivot Table will have one column that contains the values of the row field and another column to its right that contains the corresponding summary values for the data field. If you specify a column field only, your Pivot Table will have a top row that holds the values of the column field and a row beneath that holds the corresponding summary values of the data field.
AlamedaServices.com
17
Sum of Annual SalesManufacturer TotalDesire $1,326,000Marco Polo Jeans $874,000New Fashion $328,000Vector $650,000Young Look $922,000Grand Total $4,100,000
Sum of Annual Sales Year1999 2000 2001 Grand Total
Total $1,318,000 $1,372,000 $1,410,000 $4,100,000
Row‐only Pivot Table
Column‐only Pivot Table
AlamedaServices.com
18
The Pivot Table gets its name because it’s easy to modify, or pivot (turn), the positions of the Pivot Table fields. Imagine a point at the upper left‐hand corner of the Pivot Table as the pivot point. You can drag and drop a row field up and to the right, making it a column field. And you can drag and drop a column field down and to the left, making it a row field. As mentioned earlier, although you can return to the Wizard’s layout view to accomplish this layout change, it’s easier to do it on the fly without using the Wizard.
AlamedaServices.com
19
Using <wine.xls> file
State Jan-2000 Feb-2000 Mar-2000 Apr-2000 May-2000 Jun-2000 Jul-2000 Sep-2000 Oct-2000 Nov-2000 Dec-2000CA 849.9 1065 1013.05 1612.6 1776.8 1426.8 1606.55 3155.7 1871.7 2014.7 1935.5MA 958 1309NJ 1256.8 1151.4 1016.4 982.6 928 1559.4 1050.6 2341.9 902.8 1163.2 923.4NY 1552.8 705 603.5 703.2 1324.9 977.4 998.9 1825.4 1172.8 970.5 1244.4Grand Total 3659.5 2921.4 2632.95 4256.4 4029.7 3963.6 3656.05 7323 3947.3 5457.4 4103.3
Now lets try to make this a bit more complicated.What if you wanted to see what type of product was sold in each State?
Another Example
AlamedaServices.com
20
Sum of Sales MonthState Type Jan-2000 Feb-2000 Mar-2000 Apr-2000 May-2000 Jun-2000 Jul-2000 Sep-2000 Oct-2000 Nov-2000CA Red 592.5 648 648 799.2 913 649 910.5 2204.2 1102.2 1305.7
White 257.4 417 365.05 813.4 863.8 777.8 696.05 951.5 769.5 709CA Total 849.9 1065 1013.05 1612.6 1776.8 1426.8 1606.55 3155.7 1871.7 2014.7MA Red 591 906
White 367 403MA Total 958 1309NJ Red 606 342 342 528 466.5 750 685.2 2076.4 252 786.2
White 650.8 809.4 674.4 454.6 461.5 809.4 365.4 265.5 650.8 377NJ Total 1256.8 1151.4 1016.4 982.6 928 1559.4 1050.6 2341.9 902.8 1163.2NY Red 1166.4 447 443.5 568.2 1049.4 720 364.5 906 399 628.5
White 386.4 258 160 135 275.5 257.4 634.4 919.4 773.8 342NY Total 1552.8 705 603.5 703.2 1324.9 977.4 998.9 1825.4 1172.8 970.5Grand Total 3659.5 2921.4 2632.95 4256.4 4029.7 3963.6 3656.05 7323 3947.3 5457.4
Select any cell within the existing Pivot Table, then select the menu item Data ‐ Pivot Tables… you will go back to the Wizard at step 3.
AlamedaServices.com
21
Sum of Sales MonthType State Jan-2000 Feb-2000 Mar-2000 Apr-2000 May-2000 Jun-2000 Jul-2000 Sep-2000 Oct-2000 Nov-2000Red CA 592.5 648 648 799.2 913 649 910.5 2204.2 1102.2 1305.7
MA 591 906NJ 606 342 342 528 466.5 750 685.2 2076.4 252 786.2NY 1166.4 447 443.5 568.2 1049.4 720 364.5 906 399 628.5
Red Total 2364.9 1437 1433.5 2486.4 2428.9 2119 1960.2 5186.6 1753.2 3626.4White CA 257.4 417 365.05 813.4 863.8 777.8 696.05 951.5 769.5 709
MA 367 403NJ 650.8 809.4 674.4 454.6 461.5 809.4 365.4 265.5 650.8 377NY 386.4 258 160 135 275.5 257.4 634.4 919.4 773.8 342
White Total 1294.6 1484.4 1199.45 1770 1600.8 1844.6 1695.85 2136.4 2194.1 1831Grand Total 3659.5 2921.4 2632.95 4256.4 4029.7 3963.6 3656.05 7323 3947.3 5457.4
Pivot it!
AlamedaServices.com
22
Now, let say we want to see both Sales and Margin side by side so that we can compare them. We could create another pivot table. It is better to base the new Pivot Table on the existing Pivot Table, because this way Excel uses the same memory cache for both Pivot Tables thus making sure you do not run out of memory on large Tables.
Select a blank cell on your worksheet and start the Pivot Table Wizard. On the first screen, check the option button that says the data resides in Another Pivot Table;
Creating another Pivot Table based on an existing Table
AlamedaServices.com
23
AlamedaServices.com
24
AlamedaServices.com
25
Pivot Table using data from the above Pivot TableSum of Quanti MonthType State 1/1/00 2/1/00 3/1/00 4/1/00 5/1/00 6/1/00 7/1/00 9/1/00 10/1/00Red CA 31 28 48 51 56 44 69 116 59
MA 28NJ 32 17 17 42 33 36 36 112 17NY 60 17 25 29 54 30 18 54 14
Red Total 123 62 90 150 143 110 123 282 90White CA 18 21 28 55 58 59 50 65 57
MA 25NJ 43 48 39 37 31 48 27 18 43NY 21 18 10 9 19 18 44 62 52
White Total 82 87 77 126 108 125 121 145 152Grand Total 205 149 167 276 251 235 244 427 242
Original Pivot TableSum of Sales MonthType State Jan-2000 Feb-2000 Mar-2000 Apr-2000 May-2000 Jun-2000 Jul-2000 Sep-2000 Oct-2000Red CA 592.5 648 648 799.2 913 649 910.5 2204.2 1102.2
MA 591NJ 606 342 342 528 466.5 750 685.2 2076.4 252NY 1166.4 447 443.5 568.2 1049.4 720 364.5 906 399
Red Total 2364.9 1437 1433.5 2486.4 2428.9 2119 1960.2 5186.6 1753.2White CA 257.4 417 365.05 813.4 863.8 777.8 696.05 951.5 769.5
MA 367NJ 650.8 809.4 674.4 454.6 461.5 809.4 365.4 265.5 650.8NY 386.4 258 160 135 275.5 257.4 634.4 919.4 773.8
White Total 1294.6 1484.4 1199.45 1770 1600.8 1844.6 1695.85 2136.4 2194.1Grand Total 3659.5 2921.4 2632.95 4256.4 4029.7 3963.6 3656.05 7323 3947.3
AlamedaServices.com
26
Drag the Type Field button from the Row area to the Page area;
Using Page Fields
AlamedaServices.com
27
Notice that sales for all product types are shown, and that a small arrow is placed beside the (All) label next to the Type field. Click on this small arrow, a dropdown box appears that allows you to select one of the Type values (either Red or White). Try this and watch the data change to show just White or Red products.
AlamedaServices.com
28
It is a little difficult to pick trends over the twelve month data period. Select the Month field by Clicking on the Month label on the Pivot Table. Then use menu item Data‐Group and Outline‐Group… or Click on the Group toolbar button. A dialog will ask how you wish to group the Month Field, select the Quarters option and Click Finish.
Grouping Data
AlamedaServices.com
29
Note various formatting options used along with this Pivot Table.
Sum of Sales MonthState Type Qtr1 Qtr2 Qtr3 Qtr4 Grand TotalCA Red $1,889 $2,361 $3,115 $3,955 $11,319
White $1,039 $2,455 $1,648 $1,867 $7,009CA Total $2,928 $4,816 $4,762 $5,822 $18,328MA Red $591 $906 $1,497
White $367 $403 $770MA Total $958 $1,309 $2,267NJ Red $1,290 $1,745 $2,762 $1,655 $7,451
White $2,135 $1,726 $631 $1,335 $5,826NJ Total $3,425 $3,470 $3,393 $2,989 $13,277NY Red $2,057 $2,338 $1,271 $1,670 $7,335
White $804 $668 $1,554 $1,718 $4,744NY Total $2,861 $3,006 $2,824 $3,388 $12,079Grand Total $9,214 $12,250 $10,979 $13,508 $45,951
AlamedaServices.com
30
Sum of Sales MonthState Group Qtr1 Qtr2 Qtr3 Qtr4 Grand TotalCA Blend $330 $685 $1,021 $1,865 $3,902
Melot $180 $378 $54 $252 $864Pinot Noir $708 $626 $1,240 $1,167 $3,741Riesling $668 $2,135 $1,558 $1,124 $5,485Semillon $372 $320 $90 $743 $1,524Shiraz $671 $672 $800 $671 $2,813
CA Total $2,928 $4,816 $4,762 $5,822 $18,328MA Blend $330 $786 $1,116
Pinot Noir $120 $120Riesling $207 $403 $610Semillon $160 $160Shiraz $261 $261
MA Total $958 $1,309 $2,267NJ Blend $336 $1,720 $400 $2,456
Melot $468 $162 $342 $972Pinot Noir $822 $708 $772 $386 $2,688Riesling $1,571 $1,264 $631 $1,175 $4,641Semillon $564 $461 $160 $1,185Shiraz $539 $270 $527 $1,335
NJ Total $3,425 $3,470 $3,393 $2,989 $13,277NY Blend $1,481 $1,651 $666 $501 $4,299
Melot $108 $108 $198 $414Pinot Noir $313 $579 $234 $708 $1,834Riesling $362 $668 $1,074 $1,436 $3,540Semillon $442 $480 $282 $1,204Shiraz $263 $263 $263 $788
NY Total $2,861 $3,006 $2,824 $3,388 $12,079Grand Total $9,214 $12,250 $10,979 $13,508 $45,951
Creating another table based on previous table using GROUP” field.
AlamedaServices.com
31
Select a cell anywhere on the Pivot Table and call the Pivot Table Wizard. Sum of Sales is shown in the Data area, Double‐Click this. Notice that you can show the sum of sales or the count of the number of sales during a period, or several other calculations. For now, leave the selection at Sum. Click on the Options button, then select % of row from the Show data as: dropdown list.
Field calculations
AlamedaServices.com
32
Sum of Sales MonthState Group Qtr1 Qtr2 Qtr3 Qtr4 Grand TotalCA Blend 8.46% 17.56% 26.17% 47.81% 100.00%
Melot 20.83% 43.75% 6.25% 29.17% 100.00%Pinot Noir 18.93% 16.73% 33.15% 31.19% 100.00%Riesling 12.18% 38.93% 28.41% 20.49% 100.00%Semillon 24.38% 20.99% 5.88% 48.75% 100.00%Shiraz 23.84% 23.89% 28.43% 23.84% 100.00%
CA Total 15.98% 26.28% 25.98% 31.76% 100.00%MA Blend 0.00% 29.57% 0.00% 70.43% 100.00%
Pinot Noir 0.00% 0.00% 0.00% 100.00% 100.00%Riesling 0.00% 33.93% 0.00% 66.07% 100.00%Semillon 0.00% 100.00% 0.00% 0.00% 100.00%Shiraz 0.00% 100.00% 0.00% 0.00% 100.00%
MA Total 0.00% 42.26% 0.00% 57.74% 100.00%NJ Blend 0.00% 13.68% 70.02% 16.30% 100.00%
Melot 48.15% 16.67% 0.00% 35.19% 100.00%Pinot Noir 30.58% 26.34% 28.72% 14.36% 100.00%Riesling 33.84% 27.25% 13.60% 25.31% 100.00%Semillon 47.59% 38.91% 0.00% 13.50% 100.00%Shiraz 0.00% 40.34% 20.22% 39.44% 100.00%
NJ Total 25.79% 26.14% 25.55% 22.52% 100.00%NY Blend 34.46% 38.39% 15.49% 11.65% 100.00%
Melot 0.00% 26.09% 26.09% 47.83% 100.00%Pinot Noir 17.07% 31.57% 12.76% 38.60% 100.00%Riesling 10.24% 18.87% 30.33% 40.57% 100.00%Semillon 36.71% 0.00% 39.87% 23.42% 100.00%Shiraz 33.33% 0.00% 33.33% 33.33% 100.00%
NY Total 23.69% 24.88% 23.38% 28.05% 100.00%Grand Total 20.05% 26.66% 23.89% 29.40% 100.00%