Accessing and Analyzing Data with Microsoft Excel (Bpg-Other)

Understanding the terminology and basic layout is only one third of mastering PivotTable report skills. The next third is creating a PivotTable report, and the final third includes using features such as the PivotTable field list, the PivotTable toolbar, the PivotTable report shortcut menu, and filtering PivotTable report data.

To get started, a convenient way to create PivotTable reports and PivotChart reports in Excel is by using the PivotTable And PivotChart Report wizard. To start the wizard, click PivotTable And PivotChart Report on the Data menu. On the wizard’s first screen, shown in Figure 4-10, you need to identify the source or location of the data you want to analyze and select the option for which type of report to create. Select PivotChart Report (With PivotTable Report) if you want to create a PivotTable report with a PivotChart report that uses the PivotTable report as its data source.

Figure 4-10: The PivotTable And PivotChart Wizard - Step 1 Of 3.

The options for data sources include the following:

If the data is stored in another Excel file, you should have that file open at the same time you run the PivotTable And PivotChart Wizard. Switch to the other Excel file and select the cells you want to use as the basis of the pivot report. Then click Next. (You can also click the Browse button, select an Excel worksheet, and then specify the cell range at the end of the file name in the Range box. Having the external worksheet open is the easier operation.)

If you select the Create A Single Page For Me option, you’ll see the dialog box shown in Figure 4-14. Click the Range box, and then select a group of cells that you want to include in your PivotTable report. Click Add to add the group of cells, and then designate the other groups of cells that you want to include in your PivotTable report.

Figure 4-14: This PivotTable And PivotChart Wizard - Step 2b Of 3 page is displayed if you choose to have the wizard create a single page field.

If you choose to create your own page fields, you’ll see the dialog box shown in Figure 4-15. Click the Range box, select a group of cells that you want to include in your PivotTable report, and then click Add. Follow this step for each group of cells that you want to include in your PivotTable report. Click the number of page fields that you want, and give each item a label.

Figure 4-15: This PivotTable And PivotChart Wizard - Step 2b Of 3 page lets you create your own page fields.

Note

If the data is stored in other Excel files, you should have those files open at the same time you run the PivotTable And PivotChart Wizard. Switch over to the other open Excel files, and, file by file, select the cell groups that you want to use as the basis of the pivot reports. After you select each individual cell group, click Add. (You can also use the Browse button and add the cell reference to the sheet selected in the Range box.)

Step 3 of the PivotTable And PivotChart Wizard appears in Figure 4-17. In this step you have the option to have Excel create a new worksheet and place the PivotTable report on it, or have Excel place the PivotTable report on an existing worksheet. If you click the Existing Worksheet option, click the accompanying box and then click the cell on the worksheet where you want the PivotTable report to start.

Figure 4-17: The PivotTable And PivotChart Wizard - Step 3 Of 3 page.

Tip

Click the Layout button to construct the PivotTable report within the wizard instead of constructing the PivotTable report on the worksheet itself. This option is especially helpful if your source data is from a large external database, in which case the worksheet layout may be too time-consuming.

Tip

Click the Options button to set additional PivotTable report options; for example, whether grand totals are automatically displayed for columns and rows, what to display for empty rows (such as “N/A”), and how often to automatically refresh the report’s data.

After you have created a PivotTable report, there are several additional options and features available to you, including the PivotTable field list, the PivotTable toolbar, and the PivotTable report shortcut menu. You can use these options and features to refine the ways in which pivot reports present and analyze your data.

Using the PivotTable Field List

The PivotTable Field List window, included in Excel 2002, is shown in Figure 4 18. The window has two main areas. The field list itself contains the fields in the data source. As you saw in the exercise earlier in this chapter, to include a field in a PivotTable report, you drag the field from the list to the area where it’s required on the PivotTable report.

Figure 4-18: The PivotTable field list.

At the bottom of the PivotTable field list is the drop zone list, which provides an alternative way of including fields in a PivotTable report, especially for users who have difficulty dragging fields to precise areas in a PivotTable report. You can use the drop zone list to add fields to a PivotTable more quickly than by dragging fields. To use the drop zone list, click a field in the field list, click an entry in the drop zone list below the field list, and then click the Add To button.

To remove a field from a PivotTable report, drag a field off the PivotTable report to an unused portion of the Excel worksheet. You don’t have to drag the field back to the PivotTable field list, and you don’t have to worry about the field disappearing from the PivotTable field list either.

Tip

To make the best use of screen real estate, when you begin adding fields to a PivotTable report, add the field with the fewest number of items to the page area, the field with the next fewest number of items to the column area, and then other fields to either the page or row areas.

Putting It Together

Imagine you are a real estate sales manager and you want to quickly create and analyze a PivotTable report from last year’s sales figures for the United States. In this exercise, you will create a PivotTable report, dragging items from the PivotTable field list to the PivotTable report and using the drop zone list to include items in the PivotTable report. You will switch perspectives in the PivotTable report to analyze the data and create a second PivotTable report based on the first PivotTable report while leaving the first PivotTable report’s layout unchanged.

  1. Start Excel, and open the HomeSale.xls file in the Chap04 folder.

  2. On the United States worksheet, click cell A1.

  3. On the Data menu, click PivotTable And PivotChart Report and then click Finish in step 1 of the wizard.

  4. From the PivotTable field list, drag the Month icon to the Drop Row Fields Here area.

  5. In the PivotTable field list, click the Gross Sales icon, click Data Area in the drop zone list, and click Add To.

  6. In the PivotTable field list, click the Region icon, click Column Area in the drop zone list, and click Add To. Compare your results to Figure 4-19.

    Figure 4-19: The sum of gross sales across regions by month.

  7. Experiment with switching perspectives by dragging the Month field to the column area, dragging the Region field to the row area, and dragging either the Month field or the Region field to the page area.

  8. Now create a second PivotTable report that gets its data from the first PivotTable report. Click any cell outside the PivotTable report, and then click PivotTable And PivotChart Report on the Data menu.

  9. Select the option Another PivotTable Report Or PivotChart Report, and then click Finish.

  10. As you experiment with the new PivotTable report, notice that the first PivotTable report’s layout doesn’t change. Creating a second report is helpful when you want to present two perspectives of the same data for side-by-side analysis.

Using the PivotTable Toolbar and Shortcut Menu

The PivotTable toolbar, shown in Figure 4-20, provides commands that you use to format the data in your report and to organize the data for analysis.

Figure 4-20: The PivotTable toolbar and PivotTable menu.

From left to right across the toolbar, the commands include

To see the effects of using the Hide Detail and Show Detail buttons, click a field label in a PivotTable report’s row area or column area, click Show Detail, click a field containing the detail you want to see, and then click OK. The PivotTable report’s layout changes to show detailed data for just that item. Click Hide Detail to remove the detailed data. To return to the original report layout, click Undo on the Edit menu until you return to the layout you want.

The PivotTable menu, also shown in Figure 4-20, contains the following commands:

Additionally, when you right-click in any PivotTable report area, a shortcut menu appears. Many of the shortcut menu commands are identical to their PivotTable toolbar counterparts. The following commands are available only on the PivotTable report shortcut menu:

Your Turn

In this exercise, you will use some of the commands on the PivotTable toolbar to format and display a PivotTable report.

  1. Start Excel, and open the HomeSale.xls file in the Chap04 folder. If it is already open, close the file (do not save it) and open the file again.

  2. Click cell A1.

  3. On the Data menu, click PivotTable And PivotChart Report and then click Finish in the wizard.

  4. From the PivotTable field list, drag the Month icon to the Drop Row Fields Here area. Drag the Region icon to the Drop Column Fields Here area, and drag the Gross Sales icon to the Drop Data Items Here area.

  5. On the PivotTable toolbar, click the Format Report button.

  6. Click the Report 2 picture, and then click OK.

  7. Click the Chart Wizard button. A linked PivotChart is created.

  8. On the worksheet labeled Sheet1, click cell C5.

  9. On the PivotTable toolbar, click Field Settings.

  10. Click the Number button, and then click Currency in the Format Cells dialog box.

  11. In the Decimal Places box, type 0.

  12. Click OK, and then click OK again. The sales figures are formatted as currency.

  13. From the PivotTable field list, drag the Region icon to the Drop Page Fields Here area.

  14. On the PivotTable toolbar, click the PivotTable menu and then click Show Pages.

  15. Click OK. Excel creates worksheets labeled East, North, South, and West, showing views of the different regions.

Field Settings

The Field Settings button on the PivotTable toolbar opens the PivotTable Field dialog box. This dialog box provides a variety of options; the options displayed in the dialog box depend on the sort of field or item you select in the PivotTable. The options provide the means for changing the way data is displayed in a PivotTable, including summarization options and a set of custom calculations that you can use to compare the items in your data.

Clicking any PivotTable report field and then clicking the Field Settings button always displays the following two options:

Clicking a page, row, or column field and then clicking the Field Settings button gives you the following options:

If your PivotTable report includes more than one row field, clicking an outer row field (any row that isn’t the one closest to the data) and then clicking the Field Settings button adds the Layout button. The PivotTable Field Layout dialog box provides options for you to display the field’s items in tabular or outline form and to insert page breaks between items for printing purposes.

Clicking a data field and then clicking the Field Settings button provides the following options:

Filtering PivotTable Report Fields

So far, you have learned how to create, format, and rearrange fields in a PivotTable report. You can also filter PivotTable report fields to match specific criteria.

To filter PivotTable report data, with the PivotTable report active, click an arrow in the PivotTable report associated with a row field, column field, or data field, or the list next to a page field. You’ll see a menu such as the one shown in Figure 4-21.

Figure 4-21: List of items for the Agent ID field; you can filter the data to show records for all agents, one agent, or a particular combination.

For row fields, column fields, and data fields, select or clear check boxes to display or hide fields. For page fields, click the item in the list associated with the page of data that you want to display.

Putting It Together

In this exercise, you will find the top five sales months for the East region’s home sales, sorted in order with the highest sales month at the top of the list. You will accomplish this by filtering a PivotTable report to show only East region sales figures and then use the Sort And Top 10 dialog box to show only the top five sales months, sorted in descending order.

  1. Start Excel, and open the HomeSale.xls file in the Chap04 folder. If the file is already open, close it (do not save the file) and reopen the file.

  2. On the worksheet labeled United States, click cell A1.

  3. On the Data menu, click PivotTable And PivotChart Report and then click Finish in the wizard.

  4. From the PivotTable field list, drag the Month icon to the Drop Row Fields Here area. Drag the Region icon to the Drop Page Fields Here area, and drag the Gross Sales icon to the Drop Data Items Here area.

  5. In cell B1, click the arrow, click East, and then click OK. Compare your results to Figure 4-22. Only figures for the East region are displayed.

    Figure 4-22: Filtering data for the East region in the Region field.

  6. Click cell A4. Open the PivotTable menu, and then click Sort And Top 10.

  7. Click the Descending option. In the Using Field list directly below, select Sum of Gross Sales.

  8. Click the On option. In the box next to the Top box, replace the number 10 with the number 5. In the Using Field list directly below, select Sum of Gross Sales.

  9. Click OK, and compare your results to Figure 4-23. July (month number 7) had the highest sales month for the East region.

    Figure 4-23: Top five sales months, sorted in descending order, for the East region.

Creating and Using Calculated Fields and Calculated Items

The fields and items that you’ve analyzed so far correspond to specific values in a group of data records. You can also create fields and items, known as calculated fields and calculated items, that are calculated on the basis of specific values. The calculated values can then be used as if they were fields and items that already exist in the group of data records. For example, you might want to calculate sales ratios or merge geographical locations to enhance the level of your PivotTable report’s summarizations.

Note

You cannot create calculated fields or calculated items in reports based on online analytical processing (OLAP) data. For more information about OLAP, see Chapter 7.

To create a calculated field, first click a field in an active PivotTable report. Click the PivotTable menu, point to Formulas, and then click Calculated Field. The Insert Calculated Field dialog box appears, as shown in Figure 4-24. Type a name and formula to use for the field, click Add to place the field in the PivotTable field list, and then click OK.

Figure 4-24: The Insert Calculated Field dialog box.

Note

Calculated fields always use only the SUM summary function.

To create a calculated item, you first click an item in an active PivotTable report. On the PivotTable toolbar, click the PivotTable menu, point to Formulas, and click Calculated Item. The Insert Calculated Item dialog box appears, as shown in Figure 4-25. Type a name and formula to use for the item, click the Add button to add the item to the PivotTable report, and then click OK.

Tip

Click a field in the Fields list if you do not want to type field names manually into the Formula box. For calculated items, click an item in the Items list if you do not want to type item names into the Formula box. Click the Add button to add more calculated items or calculated fields without closing the Insert Calculated Item or Insert Calculated Field dialog box.

Figure 4-25: The Insert Calculated Item dialog box.

Your Turn

In this exercise, you will create a field that calculates a sales agent’s commission and create a calculated item that represents a sales agent’s overhead proceeds for sales in Washington state.

  1. Start Excel, and open the HomeSale.xls file in the Chap04 folder. If the file is already open, close it (do not save the file) and then reopen the file.

  2. On the worksheet labeled West Region, click cell A1.

  3. On the Data menu, click PivotTable And PivotChart Report and then click Finish in the wizard.

  4. Build the PivotTable report by dragging the Month icon from the PivotTable field list to the Drop Page Fields Here area, the Agent ID icon to the Drop Row Fields Here area, the State icon to the Drop Column Fields Here area, and the Sale Price icon to the Drop Data Items Here area.

  5. Click cell A5.

  6. On the PivotTable toolbar, click the PivotTable menu, point to Formulas, and then click Calculated Field.

  7. In the Name list, type Commission.

  8. In the Formula box, type = 'Sale Price' * .0035.

  9. Click Add. Compare your results to Figure 4-26, and then click OK. The Commission field is added to the PivotTable field list and the PivotTable report.

    Figure 4-26: The insert calculated field dialog box for the Commission field.

  10. Click cell C4. On the PivotTable toolbar, click the PivotTable menu, point to Formulas, and click Calculated Item.

  11. In the Name list, type WA Overhead Proceeds.

  12. In the Formula box, type = WA * 0.00175.

  13. Click Add. Compare your results to Figure 4-27, and then click OK. The calculated item is added to the PivotTable report.

    Figure 4-27: The Insert Calculated Item dialog box for the WA Overhead Proceeds field.

Категории