COMM 391 Winter 2014 Term 1 Tutorial 1: Microsoft Excel - Creating Pivot Table The purpose of this tutorial is to enable you to create Pivot Table to analyze worksheet data in Microsoft Excel. You should download the sample Excel file, c391_excel_t1.xlsx, from the UBC Connect as the foundation to create Pivot Tables in this tutorial. What is a Pivot Table? A Pivot Table is a powerful, interactive data mining feature that enables you to summarize and analyze data, especially helpful when working with large datasets. You can group data into one or more categories and perform a variety of calculations without altering the original dataset. The most important benefit of a Pivot Table is that it is dynamic. You can easily and quickly pivot, or rearrange, data to analyze them from different viewpoints, such as expanding or collapsing details, organizing and grouping data differently, and switching row and column categories. Viewing the Pivot Table from different perspectives helps you more easily identify trends and patterns among the variables in the data that might not be obvious from looking at the data from only one viewpoint. Creating Pivot Table Before you create a Pivot Table, ensure the data source is well structured. To consolidate and aggregate data, at least one column must have duplicate values, such as the same city, state, or customer name for several records. You then use these columns of duplicate values to create categories for organizing and summarizing data. Another column must have numeric values that can be aggregated to produce quantitative summaries, such as averages or sums. A Pivot Table is composed of four areas: Values The area that calculates. This area is required to have at least one field and one calculation on that field in it, e.g. sum, count, average, etc. Rows It is composed of the headings that go down the left side of the Pivot Table. It is possible to have no fields. Columns It is composed of the headings that stretch across the top of columns in the Pivot Table. It is possible to have no fields. Filter It is an optional set of one or more drop-downs at the top of the Pivot Table. It enables you to filter your results dynamically. COMM 391 Winter 2014 Term 1 Tutorial 1 Page 1
Filters Columns Rows Values 1) Create a Pivot Table to show the amount paid for each type of fruit by each person according to the day of purchase (as shown above). (Before you create a Pivot Table, ensure the data source is well structured.) Key Steps: a. Select the Raw Data1 worksheet. b. Click on any single cell in the dataset. c. Click the Insert tab (in the Ribbon) and find the Tables group. d. Select PivotTable to open the Create PivotTable dialog box. e. Accept the default and click OK. f. Excel adds a new worksheet that contains an empty Pivot Table report. Next to that is the Pivot Table Field List dialog box. This dialog box helps you build your Pivot Table. g. Drag & drop the Names field (from the PivotTable Field List) to the Row Labels box and the Fruit field to the Column Labels box. COMM 391 Winter 2014 Term 1 Tutorial 1 Page 2
h. Drag & drop the Price field to the Values box. (Click on the field in the Values box and select Value Field Settings. Choose the type of calculation that you want.) i. Drag & drop the Days field to the Report Filter box. j. Save the spreadsheet. You should see the Pivot Table as shown below. Does it work? (Correct any errors if necessary.) Adding Layers to a Pivot Table 2) Modify the Pivot Table to show the amount paid for each type of fruit by each person according to the day of purchase (as shown below). COMM 391 Winter 2014 Term 1 Tutorial 1 Page 3
Key Steps: a. Select the Pivot Table created above. b. Drag & drop the Days field (from the PivotTable Field List) to the Row Labels box. c. You should see the Pivot Table as shown above. Does it work? (Correct any errors if necessary.) Bringing External Data into Pivot Table 3) Create a Pivot Table based on data from an external source. Key Steps: a. Insert a new worksheet. b. Click the Insert tab (in the Ribbon) and select PivotTable to open the Create PivotTable dialog box. c. Select the Use an External Data Source option and click the Choose Connection button. All the connections that Excel can find are shown in the Existing Connection dialog box. d. Click Browse for More button to open the Select Data Source dialog box. e. Type your destination s URL in the File name box and click Open. f. Click next to the table you want to select, then click Import. g. Excel imports the data into your worksheet. Does it work? (Choose another data source if necessary.) i. Alternatively, click the Data tab (in the Ribbon) and select From Web to open the New Web Query dialog box. Then enter your destination s URL in the Address box. COMM 391 Winter 2014 Term 1 Tutorial 1 Page 4
Practice: Please use the Raw Data2 worksheet for the following exercises. 1) Create a Pivot Table to show the number of pubs in each pub type, by location type (as shown below). 2) Create a Pivot Table to show the maximum percentage of food sold by pub type (as shown below).. 3) Create a Pivot Table to show the average drinks sold by location type (as shown below.) 4) Create a Pivot Table to show the number of pubs by the average of drinks sold per month and group them by the class name (as shown below.) (Hint: Group the average drinks sold per month according to Table 1 shown below.) Table 1 - End of document - Class Name Drinks sold range A 32500 35000 B 30000 32500 C 27500 30000 D 25000 27500 E 22500 25000 F 20000 22500 G 17500 20000 H 15000 17500 I 12500 15000 J 10000 12500 K 7500 10000 L 5000 7500 M 2500 5000 N 0-2500 COMM 391 Winter 2014 Term 1 Tutorial 1 Page 5