Creating the Pivot Table: Using Excel Data on

Một phần của tài liệu Excel 2007 PivotTables Recipes (Trang 33 - 36)

Problem

You have an Excel Table with each region’s sales on separate sheets in your workbook, and you want to combine all the data into one pivot table. All the sheets are set up identically, but each contains data for just one region. In the Create PivotTable dialog box, you can only select the data on one worksheet, so you can’t create the pivot table from all the data.

Solution

Although you can create a pivot table from data on separate worksheets, the pivot table will have limited functionality, as described in the following “Notes” section. If possible, combine all the data on one worksheet, and then create the pivot table from that source data. To create a pivot table from data on separate worksheets, you must use the PivotTable and PivotChart

Wizard, which was used to create pivot tables in Excel 2003 and earlier versions. This is not on the Ribbon, but you can open it with a keyboard shortcut, or add it to the QAT, as described in Section 1.7.

Follow these steps to create the pivot table from data on separate worksheets, as in the sample file named MultiConsolSales.xlsx.

1. On the keyboard, press Alt+D, P, or, on the QAT, click the PivotTable and PivotChart Wizard.

2. In Step 1 of the PivotTable and PivotChart Wizard, select Multiple Consolidation Ranges, and then click Next.

3. In Step 2a, select one of the page options, and then click Next. For more information on the page options, see the following “Notes” section.

4. In Step 2b, click the Range box, select the first range, and then click Add, to add it to the All Ranges list.

5. Repeat Step 4 for each of the remaining ranges, to add it to the list.

6. If you chose “I Will Create The Page Fields,” you can select each range, and assign field names, as described in the following “Notes” section.

7. Click Next and, in Step 3, select a location for the pivot table, and then click Finish.

8. If you created page fields, you can rename them on the worksheet, where they appear in the Report Filter area. For example, select the cell that contains the label Page1, and type Salesperson.

9. In the Column Labels drop-down list, hide any columns that contain meaningless data, such as Customer, which is a text field.

Notes

Creating a pivot table from multiple consolidation ranges enables you to create a pivot table from data in two or more separate Excel Tables. However, the result is not the same as a pivot table created from a single Excel Table. The first field is placed in the Row Labels area, the remaining field names are placed in the Column Labels area, and the values in those columns appear in the Values area. All the Values use the same summary function, such as Sum or Count.

You can hide or show the column items, and you can use the Report Filters to filter the data. However, there’s no setting you can change that will make a pivot table created from multiple consolidation ranges look like a regular pivot table.

To get the best results when creating a pivot table from multiple consolidation ranges, ensure that all the ranges being used are identical in setup. Each Excel Table should have the same column headings, in the same order, and contain the same type of data. The ranges can contain different numbers of rows.

The first column will be used as Row Labels in the pivot table, so move the most impor- tant field to that position. In the MultiConsolSales.xlsxsample file, the Product field is in the first position, so the data is summarized by product.

In the PivotTable and PivotChart Wizard, after you select Multiple Consolidation Ranges as the data source, Step 2a asks, “How many page fields do you want?” You can let Excel create one page field, or you can create the page fields yourself. These appear as Report Filters in the pivot table.

Choosing Create a Single Page Field for Me

If you select this option, one page field is created automatically. In Step 2b of the PivotTable and PivotChart Wizard, you aren’t presented with any options for creating the page fields. In the completed pivot table, there’s one page field, and each range in the multiple consolidation ranges is represented as a numbered item—for example, Item1, Item2, and Item3.

This makes it difficult to determine which data you’re viewing when you select one of the items from the drop-down list. However, if you’re more interested in the total amounts than in the individual ranges, this is a quick way to create the page field.

Choosing I Will Create the Page Fields

If you select this option, you can create the page fields in Step 2b of the PivotTable and Piv- otChart Wizard. To create the page fields, follow these steps:

1. In Step 2b, select each range, and add it to the All Ranges list.

2. Select the number of page fields you want to create (zero to four). In this example, there will be two page fields.

3. In the All Ranges list, select the first range.

4. You’ll use the first page field to show the salesperson names. In the drop-down list for Field One, type the name of the person whose range you have highlighted in the list.

5. Each salesperson works in one of your sales regions, and you’ll use the second page field to show the region names. In the drop-down list for Field Two, type the region name for the person whose range you have highlighted in the list, as shown in Figure 1-8.

Figure 1-8.Page fields for multiple consolidation ranges

6. Select the next range in the All Ranges list, and then repeat Steps 4 and 5. Continue until all the ranges have page labels.

Tip After you create a label, you can select that label from the drop-down list for subsequent entries.

7. Click Next, and then click Finish to close the PivotTable and PivotChart Wizard.

8. In the pivot table, the page fields you created are shown as Report Filters, with the labels, Page1 and Page2. You can change the labels by typing over them. Select the cell that has the Page1 label, and type Salesperson, and then select the cell that has the Page2 label, and type Region.

Một phần của tài liệu Excel 2007 PivotTables Recipes (Trang 33 - 36)

Tải bản đầy đủ (PDF)

(259 trang)