Successfully reported this slideshow.
Upcoming SlideShare
×

# Pivot tableinfo

819 views

Published on

Published in: Education, Technology
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

### Pivot tableinfo

1. 1. EXCEL PIVOT TABLEDavid Geffen School of Medicine, UCLA Dean’s Office Oct 2002
2. 2. Table of ContentsPart I – Creating a Pivot TableExcel Database……………………………………………..…………….….….….3What is a Pivot Table……………………………………….….……….…….....…3Creating Pivot Tables (Step-by-Step) …………………….….…………...…..…...5Setting up the Layout Area…………………………………….………...….….….6Graphing Your Report…………………………………….…….……..….….…….8Editing your Graph………………………………………….…………….….…….9Part II – Customizing a Pivot TableRedesigning the Pivot Table Report…………………………….….……..………10Including an Additional Data Field ………………………………..……..………11Using the “Page” Option……………………………………….…………………12Displaying Pages on Separate Worksheets………………………….…………….13Representing Your Dollar Amounts as Percentages of a Column or a Row……...15Displaying the Detail Data Behind a Summarized Amount………………………17Sorting a Pivot Table Report……………………………………………………...17Collapsing and Expanding a Pivot Table………………………………………....18Hiding a Row or Column Item……………………………………………………19Suppressing Subtotals…………………………………………………………..…20“Copy – Paste Special – Value” a Pivot Table Report……………………………22Changing Field Button Labels ……………………………………………………24Part III – Miscellaneous Excel Features and TricksSorting………... …………………………………………………………..………25Subtotaling…… …………………………………………………………..………26Filtering………. …………………………………………………………..………30Auto Formatting …………………………………………………………..………34Sum Without Formulas…..…………………………………………………….…..35Print a Title on Multiple Pages……………………………………………….……36Get a List of All Worksheets in Your Workbook …………………………………36Viewing All Formulas………………………………………………………..…….37Using “Form” to facilitate Viewing and Editing Excel Database………….………38Wrap Text……………………………………………………………………..……38Print Column Letters and Row Numbers…………..….…...….…………...………39 2
4. 4. You can even make the report look nice as follows, using “Autoformat” which is also explained in this manual onpage 34: 4
5. 5. Creating Pivot Tables (Step-by-Step)Before You StartMake sure you pick one cell in the body of your database, meaning any cell below the column labels where there isdata. Excel will recognize the boundaries of your database.PivotTable Wizard Step 1 of 3On the menu bar click on “Data”, then click on “Pivot Table and PivotChart Report”, select the first option which is“Microsoft Excel list or Database” and click on “Next”.PivotTable Wizard Step 2 of 3Since your cell pointer was in the body of the database, Excel automatically knows the range of your database.Here, just click Next.PivotTable Wizard Step 3 of 3Click on “Layout” which is button to the left. Here is the heart of the pivot table where you get to design yourreport. Every field of your database appears as a button to the right. Simply drag the field(s) that you want yourdata summarized by to the “Row” and/or “Column” areas. Hit “OK” and then hit “Finish”. Keep in mind that thefollowing are just examples. You can just as easily summarize your reports by other fields that are of more interestto you.Note: If you have created filters using the Filter command on the Data menu in your Excel list, Pivot table willignore it. So it’s better to remove the filters before creating a pivot table.Also, Excel automatically includes grand totals and subtotals in the pivot table, so remove any subtotals from yourlist by choosing “Data” from the menu bar, then “Subtotals” and click on “Remove All”. Otherwise, pivot table willnot allow you to proceed through the final step and you will get an error message. 5
6. 6. Setting up the Layout AreaDrag the field “Sub Code” (on the right side of screen) to the ROW area (left side of screen). Then drag the “FiscalYear ” field to the COLUMN area. Then drag the numeric field “Expense” from the right side of the screen to the“DATA” area. Double-click hereRemember that the DATA area contains the fields you want summarized. If instead of “Sum” it defaults to “Count”,double click on “Count of Expense” and choose “Sum” as shown below and click “OK”. 6
7. 7. When done, click “OK”. Here is the result of your pivot table. Double-click here to rename the sheet.The pivot table is created on a new sheet in the workbook.You can rename the sheet that contains the pivot table by double clicking on the sheet tab name and typing your newmeaningful sheet name.When you create a pivot table, the Pivot Table toolbar will appear on your screen and it looks like this:If you don’t see this toolbar then you can choose the Toolbar command from the View menu and choose PivotTable.The best way to learn about pivot tables is through experimenting. Try positioning each field which is representedby buttons as a row category, column category, and page – the pivot table will reveal different information about theunderlying data with each layout. 7
8. 8. Graphing Your ReportYou can easily define a graph from your report. Let’s say we want to graph total travel expenses for a departmentover three fiscal years. After extracting the data and creating the pivot table, take the following steps.Step 1First, you need to select the cells for the graph. Select cells A3 to B5. Don’t include the totals in the chart.Also, don’t start from A2 or you won’t be able to select the cells.After you select the cells for the graph, look for the “Chart Wizard” button on the pivot table toolbar. Click once onthis button. . You will see the following. 8
9. 9. Editing your GraphIf you wish to edit your graph, first single click on the graph to get into the graph edit mode. If you want to changethe color of the bar, double-click on the bar you want to change.If you want to change the color of the background, double-click on the background and you can change the color.After you make your changes, click once outside the graph to exit graph edit.If you want to change the graph type to a pie or a line graph, first single click to get into the graph edit mode thenwhile your cursor is on a blank section of the chart, single click the right mouse button (shortcut) and click on“Chart Type”, select your desired chart type and click “OK” or use the chart toolbar to make changes. 9
10. 10. Part II - CUSTOMIZING A PIVOT TABLECreating a pivot table is only the first step in making it work for you. You can choose how a pivot table isorganized, formatted and calculated. You can also easily customize the portion of the source data it displays.Redesigning the Pivot Table ReportTo add detail to existing data in a pivot table, add a row or column field. To display smaller subsets of data, usepage fields. To redesign the report i.e., add a row, column, or page field, select a cell in the pivot table, and thenclick on the first button on the left of this toolbar , then click on the “Layout” button to the left of the pop upscreen to go back to the drawing board or layout screen.Try this with the first example that you tried out earlier. Drag the “Sub” and “Fiscal Year” fields off of the layoutscreen and set up the new screen to look like this…This will sum the expenses by “Sub-Object Title” for each “Project”When done, click on “OK”. You will get this report. 10
11. 11. Including an Additional Data FieldYou can summarize more than one data field from the source list or table in a pivot table. For example, if yoursource list has two numeric fields, such as gross salaries and employee benefits, you can display summary data forboth of them. Lay out the pivot table design with both numeric fields in the “Data” area as follows and click OK,And you will get this: 11
12. 12. Using the “Page” OptionThe “Page” option in the layout screen lets you look at one item at a time. You can really use this feature as a filter.Unlike items in row and column fields, the items and associated data for a page field are displayed one at a time onthe worksheet.Once again, go back to the layout screen as shown above and set up this pivot table. This again will sum theexpenses by “Sub-Object Summary” for all projects. We will use the “Page” option to look at one project at a time.To do this, drag the “Project” field from the right side to the “Page” button on the left side as shown below. Whendone, click on the “OK” button.Notice cell B1 on your finished report where the word “All” is. This means you are looking at All the projects.Click on the down arrow next to all and you will see a list of the different projects to pick from and hit “OK”. 12
13. 13. The figure below shows just the project2 expenses. Notice how the numbers have changed from the previousreport.Select some other projects, again click on cell B1 to choose another project and watch the numbers change.Keep in mind you can have more than one field in the “Page” area. The more page fields you have, the more filteredthe data is on a page. For example, a pivot table with the single page field “Project” shows total expenses for onlyone project at a time. Adding the page field Sub-Object Title filters the data even more by displaying total expensedata only for the selected sub-object title for the selected project.Displaying Pages on Separate WorksheetsNow, suppose you want to print separate reports for different projects or save them as separate reports. First, use thepage button arrow to switch back to “All”. Then follow these steps:1. Select a cell anywhere inside the pivot table.2. Click the “Show Pages” tool on the Pivot Toolbar. 13
14. 14. Depending on your layout, there can be more than one page field. The “Show Pages” dialog box is displayed,letting you select which field will determine the page breaks.3. Select Project from the list, and click OK. The following figure shows the result. 3 new worksheetsNotice that three new worksheets have been inserted into the workbook – one for each project.Grouping Your DataGrouping is another feature in pivot tables that you might find useful at times. The grouping feature is not addressedin this manual. 14
15. 15. Representing Your Dollar Amounts as Percentages of a Column or a RowEach cell in the following example is shown as a percentage of the column.The following steps will show you how to create such a report. Let’s say you are working with detail payroll datafor 3 months. Issue the Pivot Table command from the Data menu to get to the layout screen as shown below. Double-click here 15
16. 16. Double-click on the “Sum of Time” to create a custom calculation. Once you see the top section of the screenbelow, click on “Options”. Then click on the arrow next to the “Show data as” box and set that option as “% ofcolumn”.Click “OK”, then “OK” and you will get the report that we just saw with percentages in all columns. However, atfirst it will be for the whole department. Click on the arrow next to Cell B1 to pick one employee at a time.Custom calculations for PivotTable data fieldsThe following functions are available for custom calculations in data fields. If you want to create a formula to workwith PivotTable data, you can create a calculated field or a calculated item.Function ResultDifference From Displays all the data in the data area as the difference from the value for the specified Base field and Base item. The base field and base item provide the data used in the custom calculation.% Of Displays all the data in the data area as a percentage of the value for the specified Base field and Base item. The base field and base item provide the data used in the custom calculation.% Difference From Displays all the data in the data area as the difference from the value for the specified Base field and Base item, but displays the difference as a percentage of the base data. The base field and base item provide the data used in the custom calculation.Running Total In Displays the data for successive items as a running total. You must select the field for which you want to show the items in a running total.% of row Displays the data in each row as a percentage of the total for each row.% of column Displays all the data in each column as a percentage of the total for each column.% of total Displays the data in the data area as a percentage of the grand total of all the data in the PivotTable.Index Displays the data by using the following calculation:((value in cell) x (Grand Total of Grand Totals)) / ((Grand Row Total) x (Grand Column Total)) 16
17. 17. Displaying The Detail Data Behind A Summarized AmountWhen viewing summary data in a pivot table, you may observe a number that requires explanation. You can easilydisplay the source rows or records used to calculate the value of a cell in the data area. Simply double-click the cellthat requires explanation. Excel will show you the rows from the database used in the calculation. Also notice thatExcel creates a new sheet in the workbook. You may delete this sheet after you look up the detail information, ifyou don’t need it any more.Sorting a Pivot Table ReportYou can sort a Pivot Table as shown below. To try this out, in the earlier example of expenses by “Project”, pickone cell in the Expense column of the pivot table that shows expenses of project 1 and click the Descending Sortbutton and you will see sub-object title with the highest amount of expense listed on the first line.If for some reason you need to sort in reverse alphabetical order of type of expense, pick a cell in the “Sub-ObjectTitle” column and click on the icon. 17
18. 18. Collapsing and Expanding a Pivot TableSometimes, within a pivot table, you may want to view more or less detail. When there are more than one row orcolumn categories, the level of detail can be easily expanded and collapsed. Consider the following pivot table.You have the “Project” and “Sub-Object Title” fields in the “Row” section and “Sum of Expense” in the Data area.If you don’t want to see the detail sub-object amounts that make up the total of project 1, double-click on the label“project 1” , cell A5, to collapse the pivot table. The following figure shows the pivot table after cell A5 has beendouble-clicked .By double-clicking A5 again, the sub-object rows of Project 1 will show up again. 18
19. 19. Hiding a Row or Column ItemTo remove data from a single row or column in a pivot table, hide the associated item. For example, let’s say youhave pulled down payroll data for your department and you create a pivot table report showing gross earnings byfund for each person as shown below. You realize you don’t want funds 19900 and 182XX to be included in yourreport. Click on the arrow next to the heading of the “Fund” field in your pivot table report. Uncheck the fundsyou don’t want included and hit OK.Your new report will not include funds 182XX and 19900. To include them again, click on the arrow next to fundheading again and check funds 182XX and 19900.Caution: if you redesign your report and don’t include the “Fund” field in your report, even though you haveindicated to hide 2 funds, the instruction to hide will be ignored and they will be included in your total amounts. 19
20. 20. Suppressing SubtotalsSometimes you may want your summarized report to have two descriptive fields for a particular numeric field. Forexample, you may want to summarize your payroll data by person and see employee name, as well as employeenumber and total gross salary.If you layout your pivot table as follows: Double-click here to suppress totalsYour report will look like this:NOT GOOD!!!! 20
21. 21. The reason we don’t like this report, is that it gives subtotals by “Employee Name” as well as by “Employee ID”and we only need one. We don’t want the lines that say “Total” next to the employee name. In other words, wewant to suppress subtotals by Employee Name. To accomplish this, double click on the button that says “Name”.Once you see the following screen,click on “None” for “Subtotals”. Click OK and you will get the following report:MUCH BETTER!! 21
22. 22. “Copy – Paste Special – Value” a Pivot Table ReportSince a pivot table maintains a link to the source data, you cannot directly edit the data area of a pivot table. Toconvert a pivot table to a worksheet range that you can edit, copy the pivot table using the Copy command on theEdit menu (or the shortcut right mouse button). Then paste it into a new location using the Paste Special commandon the Edit menu (or the shortcut right mouse button). Select the Values option button in the Paste Special dialogbox and click “OK”.You can use this feature to use a large amount of raw data, build a pivot table, perform “copy-paste special-value”on it and basically create a new simpler database with summarized data and now use this database as source for afurther summarized and rolled up pivot table report.An example to help illustrate this concept is as follows:We have pulled down payroll report for our entire department for 3 months. We simply need to know the averagebenefit rate for each employee for this time period. To calculate that, we need to divide total benefit amount by totalgross earnings by employee to get the average benefit rate.First run a pivot report by employee for gross earnings only. Click on A1 to select the entire pivot table report. Onthe menu bar click on “Edit”, then “Copy”.Go to a new sheet, select A1. On the menu bar click on “Edit”, then select “Paste Special”. In the “Paste SpecialDialog Box”, click on “Values”, then click “OK”. 22
23. 23. You will simply get a list of employees and their total gross salary, without it being a pivot table any more. Now goback to redesign your pivot table report. Remove “Sum of Gross Earnings” and drag “Total Benefits” to the “Data”area. Perform the same “copy-paste special-value” as just described. However, instead of pasting in cell A1, pastespecial in cell C1. After formatting the numbers, this is what it will look like:Adjust the headings to say “Total Salary” and “Total Benefits”. After verifying that the names are properly lined up,delete column “C” because you already have the names in column “A”. (Delete the last line of your data whichindicates the Grand Total). Now you can add a formula in the last column, dividing total benefits by total gross.REMEMBER to give this new column a heading, i.e. “Benefit rate”, so that it becomes an integral part of yournewly created database. Format this last column to percentages. You now have a new database showing average ofactual benefit rates of all your employees based on three months of payroll data! 23
24. 24. Changing Field Button LabelsThe text that is used on the field buttons is determined by the field names in your database. These names may not bevery friendly, so you may want to change them – without changing the source database.Pick a cell in the column for which you want to rename the heading. Click the “Pivot Table Field” button on thePivot Table Toolbar . Change the name in the Pivot Table field dialog box.Or click the field button in your pivot table report– the button text displays on the formula bar. Use the formula barto edit the text, just as you would edit the contents of a cell. (Or, double-click the field button in your pivot table,and change the Name in the Pivot Table Field dialog box). 24
25. 25. Miscellaneous Excel Features and TricksSortingLet’s say you have a detail report of your expenses. To sort your entire list, just select a single cell in the column thatyou want to sort on and choose the Sort Ascending button or Sort Descending button on the toolbar. Youcan also use the sort command in the Data menu. The following shows an ascending sort based on “TransactionDescription”.Before the sort:After the sort: 25
26. 26. SubtotalingInserting subtotals is a quick way to summarize data in an Excel list or database. You do not need to enter a formulaon the worksheet to use subtotals, Excel does the work for you. To set up subtotals, first make sure there are no pre-existing subtotals in your spreadsheets. If there are, remove existing subtotals by choosing “Data” from the menubar, then choose “subtotals” and click on the button. 26
27. 27. The following picture shows a detail report with no subtotals. Before subtotaling, you must sort (explainedpreviously in this section) your data on the field for which you want subtotals. In this example you want to subtotalappropriations and expenses based on object codes. Therefore you need to sort on “object code” before you try thesubtotals. Select any cell in the object code column and click on ascending sort button.After sorting, you are ready to subtotal. To begin, choose the “Data” option from the Main Menu and “Subtotals”from the sub-menu. A screen will be presented to you in which you are prompted to respond to: “At each changein”. If you click on the button, you will see a list of all the fields in your spreadsheet. Since you want tosubtotal on object code, choose “Object Code”. 27
28. 28. At the “Use Function” function prompt, click on the button to see all the possible choices. For this example,since you want to see Summary totals, choose “Sum”. You could also count the number of entries in a group(“Count”), find the lowest value in a group (“Min”), view the average in a group (“Average”), etc...The next prompt asks: “Add Subtotal to:”. You can choose any field(s) in your spreadsheet. Usually, we want to“sum” fields that contain dollar amounts. Therefore click on the boxes next to Appropriation and Expense. Whencomplete, click the button. 28
29. 29. Here is the result of your report subtotaled by Object Code:Notice the solid lines and buttons that appear to the left. These symbols are indicative of the structure ofsubtotals. Try clicking on the first button. The button turns into a button and the individual lines thatmake up the first subtotal, get rolled up and you only see the line that has the subtotal. To unsquish, click on thebutton.Now on the buttons click on the button with number 2 on it. This provides a “roll-up” for all of the objectcodes (or any other field that you had subtotals for). In order to view your subtotaled field adjacent to the summaryvalues, highlight the column to the right of your subtotaled column by clicking on the letter at the top of thatcolumn. Freeze it (Window option from menu bar, Freeze Panes option from sub-menu). Scroll to the right by usingthe arrow button at the bottom of your screen and you will get the following:To go back to all detail, on the button, click on the button with the number 3 on it.To unfreeze panes, from the menu bar choose “Window” and then “Unfreeze Panes”. 29