Printing and Extracting Pivot Table Data

22 467 0
Printing and Extracting Pivot Table Data

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Printing and Extracting Pivot Table Data O ne of the strengths of pivot tables is the capability to change the layout and analyze data from different perspectives. Sometimes, though, you want a static picture from the pivot table and need to print the data. For the most part, pivot tables print the same as other data on a worksheet, but you can apply a few special settings to a pivot table. Some printing issues, such as printing a copy of the pivot table for each item in the Report Filter field, can be solved by programming, and examples are given in Chapter 11. After you create a pivot table, you may want to extract some of the summarized data for use in other parts of the workbook. The GetPivotData worksheet function can be used for retrieving specific data from the pivot table. Another way to extract data is to use the Show Details feature, which returns records from the source data for the selected pivot table cell. Finally, the Show Report Filter Pages feature can be used to create copies of the pivot table on newly inserted worksheets. Except where noted, the RegionSales_09.xlsx workbook is used as the sample file for the problems in this chapter. 9.1. Repeating Pivot Table Headings Problem Your pivot table spans several printed pages and the report filter, row labels, and column labels only print on the first page. You want the heading rows and labels on every page, so readers can understand the report. In your pivot table, the Product and OrderDate fields are in the Row Labels area, Region is in the Column Labels area, Category is in the Report Filter area, and Sum of TotalPrice is in the Values area. This problem is based on the RegionSales_09.xlsx workbook. Solution You can set options for the pivot table to make the heading rows and labels appear on every page when you print the pivot table. There are two settings to change: 167 CHAPTER 9 • The print titles option determines if the heading rows and columns appear at the top and left on each printed page. • The row labels option determines if row labels are repeated if their items continue on another page. Setting Print Titles Before you turn on this option, clear any entries for row and column print titles on the work- sheet, as described in the following steps. If either of these boxes contains an entry, the Set Print Titles option won’t be applied for the pivot table. 1. On the Ribbon, click the Page Layout tab, and in the Page Setup group, click Print Titles. The Page Setup dialog box opens with the Sheet tab activated. 2. Under Print titles, clear the Rows to Repeat at Top and Columns to Repeat at Left boxes, and then click OK. 3. Right-click a cell in the pivot table, and then click PivotTable Options. 4. On the Printing tab, add a check mark to Set Print Titles, and then click OK. Repeating Row Labels You can change a pivot table option so the labels appear on each page. This option has no effect if the pivot table is in the Compact Form layout, so if one of the other report layouts isn’t already applied, the first step is to select one of them. ■ Note This setting will have no effect if the pivot table is in the Tabular Form layout and the option for Merge Labels is turned on. 1. Select a cell in the pivot table, and on the Ribbon’s Design tab, in the Layout group, click Report Layout. 2. Click Show in Outline Form, or click Show in Tabular Form. The pivot table layout changes to show each field in the Row Labels area in a separate column, instead of all fields in a single column. 3. Right-click a cell in the pivot table, and then choose PivotTable Options. 4. On the Printing tab, add a check mark to Repeat Row Labels on Each Printed Page, and then click OK. 5. Click the Microsoft Office Button, and then point to Print, and click Print Preview, to see the changes to the report setup. Headings repeat on all pages, and the row labels repeat if their items continue on another page. In Figure 9-1, the Banana label is repeated at the top of Page 2. CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA168 ■ Note If you zoom in or out in Print Preview, the repeated row labels may disappear temporarily. Figure 9-1. Headings and row labels repeat in print preview. How It Works When you turn on the Set Print Titles option, it adds settings to the Print Titles boxes in the Page Setup dialog box, on the Sheet tab. To see the settings, on the Ribbon’s Page Layout tab, in the Page Setup group, click Print Titles. ■ Caution If you clear the Print Titles settings in the Page Setup dialog box after turning on the Set Print Titles option, you have to turn the Set Print Titles option off, and then turn it back on, for it to take effect. Only one pivot table per worksheet can have the Set Print Titles option selected. If the set- ting is turned on in one pivot table, the option is unavailable in the PivotTable Options dialog box for other pivot tables (see Figure 9-2). Figure 9-2. The Set Print Titles option is unavailable. When the Set Print Titles option is selected, the report filter, row labels, and column labels print on every page. If multiple pivot tables are on the worksheet, or other data, the pivot table headings also print with those. CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA 169 9.2. Setting the Print Area to Fit the Pivot Table Problem Your pivot table frequently changes size, and you have to reset the print area every time you want to print it. You would like the print area to adjust automatically, so you don’t waste paper, or print only part of the pivot table. This problem is based on the PrintArea.xlsx workbook. Solution Don’t set a print area on the sheet with the pivot table, and the entire pivot table will print, no matter what its size, although it may span several printed pages. To remove an existing print area, on the Ribbon’s Page Layout tab, in the Page Setup group, click Print Area, and then click Clear Print Area. If you’re setting a print area because other items are on the sheet that you don’t want to print, move those items to another sheet, if possible, so you can print the pivot table separately. If the items must remain on the same sheet as the pivot table, use the following technique to quickly set a print area that encompasses the entire pivot table: 1. Select a cell in the pivot table, and on the Ribbon’s Options tab, in the Actions group, click Select, and then click Entire PivotTable. 2. On the Ribbon’s Page Layout tab, in the Page Setup group, click Print Area, and then click Set Print Area. ■ Tip You can add Select Entire PivotTable and Set Print Area buttons to the Quick Access Toolbar. 9.3. Printing the Pivot Table for Each Report Filter Item Problem Several stores carry your products, and you were asked to send each store manager a printed copy of the pivot table, customized to show their sales results. You added the Store field to the Report Filter area, and you can select a store in the report filter, to show its totals in the pivot table, and then print the worksheet. However, you’d like to find a more efficient way to print the reports, because you’ll have to do this each week. This problem is based on the RegionSales_09.xlsx workbook. Solution You can use the Show Report Filter Pages feature to create a worksheet for each item in the Store report filter field. Then, you can group the worksheets and print them: CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA170 ■ Tip Before using the Show Report Filter Pages command, select (All) from the Store report filter. If a store is selected, a worksheet will not be created for that store. 1. Select a cell in the pivot table, and on the Ribbon’s Options tab, in the PivotTable group, click the arrow for Options, and then click Show Report Filter Pages (see Figure 9-3). Figure 9-3. Show Report Filter Pages command 2. In the Show Report Filter Pages dialog box, select the Store field, and then click OK. A worksheet with a copy of the pivot table is then created for each store, with the store’s name on the sheet tab, and that store is selected in the report filter. 3. To select all the worksheets created, click the sheet tab for the first store sheet at the left, and then scroll to see the last store’s sheet tab. Hold the Shift key, and click the last store’s sheet tab. ■ Caution While the sheets are grouped, any changes you make to the active sheet are also made to the other sheets in the group. 4. While the sheets are grouped, you can set the Page Setup options, if desired. On the Ribbon’s Page Layout tab, in the Page Setup group, click the commands to set the mar- gins, orientation, or other options. To open the Page Setup dialog box, click the dialog launcher at the bottom right of the Page Setup group (see Figure 9-4). Figure 9-4. Page Setup dialog launcher CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA 171 5. To print the grouped sheets, click the Microsoft Office Button, and then click Print. 6. After printing, you can delete the Store sheets that were created, or close the workbook without saving the changes. 9.4. Printing Field Items: Starting Each Item on a New Page Problem Your pivot table has Store and Product in the Row Labels area, and when you print your pivot table, you want each store’s data to start on a new page. This enables you to print the entire report, and send each store its own section. This problem is based on the RegionSales_09.xlsx workbook. Solution You can change a setting in the Store field, so each item starts on a new page in the printed report: 1. Right-click one of the Store labels in the pivot table, and then click Field Settings. 2. In the Field Settings dialog box, on the Layout & Print tab, add a check mark to Insert Page Break After Each Item. 3. Click OK, to close the dialog box. ■ Tip When starting each item on a new page, your pivot table may be easier to understand if you set the pivot table print titles, as described in Section 9.1. This repeats the pivot table headings on each page, so they’re visible with each store’s data. Notes Using the Insert Page Break After Each Item setting won’t ensure all items for a field fit on one page. It only ensures the next item will start on a new page. For fields with many items, two or more pages may be required. If several of the fields have a short list of items, your printed report could end up using an excessive amount of paper with this setting. You may prefer to turn the setting off and manu- ally adjust the page breaks in Page Break Preview. On the Ribbon’s View tab, in the Workbook Views group, click Page Break Preview. Dashed lines indicate an automatic page break and solid lines are manual page breaks. To move a page break, point to it, and drag up or down on the page. ■ Note You can’t move or delete the page breaks created by the Insert Page Break After Each Item setting. CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA172 9.5. Printing in Black and White Problem You applied the PivotTable Style Medium 16, which has a blue fill color in the cells, and it has black headings with white text. This style is attractive on the worksheet, but it’s difficult to read when you print it on your black and white printer. You’d like to print the worksheet without all the shading, so it’s easy to read and uses less toner or printer ink. This problem is based on the RegionSales_09.xlsx workbook. Solution You can change a page setup option, so the shading is removed when printing: 1. On the Ribbon’s Page Layout tab, click the dialog launcher at the bottom right of the Page Setup group. 2. In the Page Setup dialog box, on the Sheet tab, add a check mark to Black and White. 3. Click OK, to close the dialog box, or click Print Preview, to see the revised coloring. All the text is in black font, and all the fill color is removed from the cells. 9.6. Extracting Underlying Data for a Value Cell Problem Your pivot table summarizes discount amounts per store, for each category. The Category field is in the Column Labels area, Store is in the Row Labels area, and Discount is in the Values area, as Sum of Discount. One store shows a very high discount total for the Cookies category, and you’d like to see more detail on those orders. None of the other stores is close to this amount, and you wonder if an error occurred in the data, or if there’s another cause for the high amount. This problem is based on the RegionSales_09.xlsx workbook. Solution For pivot tables based on non-OLAP source data, you can use the pivot table’s Show Details feature to extract the source data. For this example, in the pivot table, simply double-click the cell that contains the high discount total. The Show Details feature extracts the records that contribute to the summarized data, and sends the records to a new sheet in the active workbook. On that sheet, you can examine the records to see if a problem exists. ■ Tip Instead of double-clicking a cell, you can right-click a cell in the Values area of the pivot table, and then, in the context menu, click Show Details. CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA 173 If you double-click a cell in the pivot table, you may see an error message that says, “Cannot change this part of a PivotTable report.” The Show Details feature may be turned off in the PivotTable Options dialog box. To turn it on, follow these steps: 1. Right-click a cell in the pivot table, and then choose PivotTable Options. 2. On the Data tab, add a check mark to Enable Show Details, and then click OK to close the PivotTable Options dialog box. How It Works The Show Details feature uses the information stored in the pivot table’s pivot cache to create a new sheet that shows the related records from the original source data. It’s a good way to investigate anomalies in the summarized data. The extracted records are copies of the original records in the source data for the pivot table. They are not connected to the original records or to the pivot table. ■ Note If you make changes in the exported records, this will have no effect on the pivot table, and the changes will not be reflected in the original records. If Show Details is used in a pivot table, all columns from the source data are shown, not just the fields currently in the pivot table layout. A new worksheet is automatically created for the extracted records; you can’t change a setting to control where the extracted records are placed. 9.7. Re-creating the Source Data Table Problem Someone accidentally deleted the worksheet that contained the source data for your pivot table, and you would like to re-create it. (Yes, you know you should have kept a backup copy!) This problem is based on the SourceData.xlsx workbook. Solution You may be able to use the pivot table’s Show Details feature to re-create the source data: 1. Ensure that none of the items in the visible fields are hidden. Each report filter field should have (All) selected, and the (Select All) item should be checked in each of the row and column fields. To clear all the filters, on the Ribbon’s Options tab, in the Actions group, click Clear, and then click Clear Filters. ■ Tip You don’t need to include all fields in the pivot table to see them in the Show Details output. A pivot table with just one field in the Values area, and nothing in the Row Labels, Column Labels, or Report Filter areas, can output all the source data when the grand total cell is double-clicked. CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA174 2. On the Ribbon’s Design tab, in the Layout group, click Grand Totals, and then click On For Rows and Columns. 3. Double-click the grand total cell at the bottom right of the pivot table. This should create a new sheet with all the records from the original source data. If the source table contained formulas, then you have to re-create them, as the Show Details feature exports the data only. If the Show Details feature doesn’t work, check that the Show Details feature is enabled, as described in Section 9.6. The original records can’t be re-created if the source data was not saved with the file. This option is set in the PivotTable Options dialog box, on the Data tab. How It Works The Show Details feature, where available, creates a new worksheet with the records from the source data included in the amount shown in the double-clicked cell. The columns are in the same order as those in the source data, and the list is formatted with the default Table style for the workbook. The records exported in the Show Details process are from the current pivot cache. If you had made changes to the source data, but you hadn’t yet updated the pivot table, those changes wouldn’t be reflected in the exported records. To see the name of the new Excel Table, select a cell in the Excel Table. On the Ribbon’s Design tab, the Table Name is visible in the Properties group, at the far left. You can change that name to the same name as the Excel Table that originally held the source data, and the pivot cache may automatically connect to the new source data. If not, you can connect to the new source range: 1. Select a cell in the pivot table, and on the Ribbon’s Options tab, click Change Data Source. In the Table/Range box, you can see the name of the original source table. 2. Select the new Excel Table, or type the name of the new Excel Table, and then click OK. ■ Tip If your pivot table is based on a named range, you may have to redefine the named range if the origi- nal range was deleted. 9.8. Formatting the Extracted Data Problem When you use the Show Details feature, the underlying data is exported to a table in a new worksheet. You don’t like the blue formatting that’s used on the new table, and you have to spend time formatting each set of records you extract. You’d like the table formatted auto- matically, using a different table style. This problem is based on the RegionSales_09.xlsx workbook. CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA 175 Solution The extracted records are formatted with the default Table Style for the workbook. To change to a different default style, follow these steps: 1. Select a cell in one of the Excel Tables in the workbook. 2. On the Ribbon’s Design tab, in the Table Styles group, click the More button, to open the Table Styles gallery. 3. Right-click a style you like, and then click Set As Default. Now, when you use the Show Details feature, the extracted records are stored in an Excel Table that uses the new default table style. Changing the default table style does not affect the number and date formatting in the extracted records. All the fields in the extracted data use the General number format, or the Short Date format. There’s no way to control the format of the data exported during a Show Details operation. After the data is exported, you can format the results. To manually format the data, use the Format Painter button on the Ribbon’s Home tab to copy the formatting from the source Excel Table and apply it to the new table. 9.9. Deleting Sheets Created by Extracted Data Problem When you use the Show Details feature, data is exported to a new worksheet. This creates extra work for you, as you have to delete all the created sheets before closing the workbook. You’d like a quick way to delete the sheets, so they don’t clutter the workbook. This problem is based on the RegionSales_09.xlsx workbook. Solution Save the workbook just before you use the Show Details feature. Then, close the workbook without saving the changes, after viewing the additional sheets created by the Show Details feature. Or, save the workbook with a new name to preserve the original workbook without the extra worksheets. ■ Note A new worksheet is automatically created for the extracted records; you can’t control where the extracted records are placed. 9.10. Using GetPivotData: Automatically Inserting a Formula Problem You want to refer to a pivot table cell in one of your worksheet formulas, so you can perform calculations using the summarized data. When you type an equal sign, and then click a cell in the pivot table, Excel inserts a GetPivotData formula: CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA176 [...]... hidden pivot table Users can change the layout of the main pivot table, and it won’t affect your GetPivotData formula results The GetPivotData function requires two arguments: =GETPIVOTDATA (data_ field ,pivot_ table) For example, the formula =GETPIVOTDATA("TotalPrice",$A$3) would return the grand total for the TotalPrice values in the pivot table located at Cell A3 ■ For non-OLAP-based pivot tables, the data_ field... OLAP-based pivot table, use the name as displayed in the Pivot Field list, for example, Sum of TotalPrice 177 178 CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA Also, you can include up to 126 pairs of pivot fields and pivot items in the GetPivotData function, after the pivot_ table argument: =GETPIVOTDATA("TotalPrice",$A$3,field1,item1, ) ■ The field/item pairs can be in any order, following the data_ field... off (see Figure 9-5) CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA Figure 9-5 The Generate GetPivotData command 9.12 Using GetPivotData: Referencing Pivot Tables in Other Workbooks Problem Your GetPivotData formula refers to a pivot table in another workbook When you open the workbook and update the links, you get a #REF! error in the GetPivotData formulas This problem is based on the Linked.xlsx... the reference How It Works The GetPivotData worksheet function extracts data from the pivot table for a specific pivot field and pivot item By default, a GetPivotData formula is automatically created when you refer to a pivot table cell in a worksheet formula You can turn this feature on or off Although the GetPivotData formula looks complex, and you’re more comfortable using a simple cell reference,... created (see Figure 9-9) This formula looks different than the other GetPivotData formulas on the worksheet, and it returns a #REF! error: =GETPIVOTDATA($A$3,"Category[Bars ;Data, Average]") 183 184 CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA Figure 9-9 GetPivotData formula for custom subtotal You’d like to fix the GetPivotData formula so it returns the correct result This problem is based on... Count, and then click OK In the pivot table, Bars, for the East region, shows a subtotal of 118 CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA 5 Select a cell outside of the pivot table, type an equal sign, and then click the subtotal cell for Bars East Press the Enter key to complete the formula The formula in the cell contains the Data reference and returns a #REF! error: =GETPIVOTDATA($A$3,"Bars... pivot table, such as =B4 This problem is based on the Insert.xlsx workbook Solution You can use a command on the Ribbon to toggle this feature on and off: 1 Select a cell in the pivot table, and then click the Ribbon’s Options tab 2 In the PivotTable group, click the arrow on the Options command 3 Click Generate GetPivotData to toggle this feature on and off (see Figure 9-5) CHAPTER 9 ■ PRINTING AND. .. reference for an OLAP-based pivot table 9.15 Using GetPivotData: Using Cell References for Value Fields Problem In your pivot table, the Quantity and TotalPrice fields are in the Values area, and Product is in the Row Labels area When you link to a cell in the pivot table, a GetPivotData formula is automatically created, and shows “TotalPrice” as the first argument: =GETPIVOTDATA("TotalPrice",$A$3,"Product","Arrowroot")... location in the table, as long as the referenced fields are still in the pivot table If the referenced fields aren’t visible in the pivot table, then the formula returns an error instead of incorrect data ■ To ensure the referenced fields and items remain visible, you could create a pivot table that is a Tip copy of the main pivot table and stored on a hidden sheet In your GetPivotData formulas, refer... =GETPIVOTDATA("" & E1,$A$3,"Product","Arrowroot") or =GETPIVOTDATA(E1 & "",$A$3,"Product","Arrowroot") 9.16 Using GetPivotData: Extracting Data for Blank Field Items Problem In the source data, some of the orders do not have a store number entered In the pivot table, the Store field is in the Row Labels area, and a (blank) item is listed You want to extract the total for this item using a GetPivotData . on and off (see Figure 9-5). CHAPTER 9 ■ PRINTING AND EXTRACTING PIVOT TABLE DATA1 78 Figure 9-5. The Generate GetPivotData command 9.12. Using GetPivotData:. ■ PRINTING AND EXTRACTING PIVOT TABLE DATA 169 9.2. Setting the Print Area to Fit the Pivot Table Problem Your pivot table frequently changes size, and

Ngày đăng: 09/10/2013, 12:20

Từ khóa liên quan

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan