Click back in the main Excel application window and repeat steps 1 and 2 for the State
4. Click back in the main Excel application window and repeat steps 1 and 2 for the State
Names worksheet and the tblStateNames table.
5. After step 4, in the Power Pivot window, across the bottom of the window you should see four tabs, each with a little chain-link icon: tblSalesData, tblRepByState, tblRegionByState, and tblStateNames. Click the tab for tblSalesData so that the main data table is visible. Then click any cell in the State Abbr column (see Figure 4-18).
Lesson 4
Figure 4-18 All four tables appear in the
Power Pivot window.
6. At the top of the Power Pivot window, in the Power Pivot ribbon, click the Design tab. In the Relationships group, click the Create Relationship button.
7. In the Create Relationship dialog box, the first field, Table 1, should display tblSalesData and the Columns list below it should show State Abbr selected. If these items are not selected, use the Table 1 drop-down arrow to select tblSalesData for the table and then click State Abbr for the column.
8. Use the drop-down to set Table 2 (the related lookup table) to tblRepByState . In the Columns list below Table 2, select State Abbr . Click OK .
9. Repeat steps 6–8 two more times, creating relationships between the tblSalesData table and the tblRegionByState table based on the State Abbr fields, and between the tblSalesData table and the tblStateNames table based on the State Abbr fields in each table.
10. Check your work: In the Power Pivot window, click the Home tab, and then in the View group, click the Diagram View button. You should see a map similar to what is shown in Figure 4-19. (You might have to resize the window or scroll around a bit to see them all well.) Hover the mouse over each of the arrows between the tables to make sure the relationship is properly defined. For example, the State Abbr field should highlight in both tables connected by each arrow. And there should be three arrows, one between tblSalesData and each of the other three tables in the data model.
You can use the Manage Relationships button on the Design tab in the Power Pivot window to create an additional relationship or to edit or delete existing relationships (also shown in Figure 4-19). If you opened the Manage Relationships window, make any changes as necessary and then click the Close button to close it.
121 Figure 4-19
Working with Advanced Charts and PivotTables
The Diagram View of the Power Pivot window and the Manage Relationships window
11. Once all of your relationships are correct, click in the Excel application window and SAVE the workbook.
12. Go back to the Power Pivot window. (If you closed the Power Pivot window, you can re- open it by clicking the Manage button on the Power Pivot tab in Excel.)
13. Click the Home tab of the Power Pivot window and then click the PivotTable button to add a new PivotTable on a New Worksheet. In the Create PivotTable dialog box, click OK .
14. In the PivotTable Fields pane, expand the field list for the tblSalesData table. Click the check box for Sales Amount on the tblSalesData table. Once the PivotTable
populates, right-click cell B4 , select Number Format , and then set the number format to Accounting with 0 Decimal places. Click OK .
15. Add Product to the PivotTable as a COLUMNS field.
16. If you are only seeing tblSalesData lists, click the ALL button underneath the title of the PivotTable Fields pane.
17. In the PivotTable Fields pane, expand the field list for the tblRegionByState table and add the Region field as a ROWS field.
18. Adjust the height of Row 1 to 90 points (120 pixels).
19. Click any cell in the PivotTable. Click the PivotTable Tools Analyze tab and then click the Insert Slicer button.
20. The Insert Slicers dialog box will have two tabs. Click the ALL tab. If the tblRepByState item is collapsed, expand it and then select the Sales Rep check box. Click OK .
21. Resize the Sales Rep slicer so it covers B1:F1 .
22. With the slicer still selected, on the Slicer Tools Options tab, in the Buttons group, use
the Columns control to increase the number of columns to 3 .
23. Use the slicer to filter the table to only Amelia Earhart and John Wayne .
24. Click the drop-down filter button in cell C3 and then point to Label Filters and select Ends With to filter the table to only those products that end in ets . Click OK . Compare your results to Figure 4-20.
Lesson 4
Figure 4-20 The completed PivotTable
using Power Pivot’s data model to manage relationships
25. SAVE the workbook. PAUSE. LEAVE the workbook open to use in the next exercise.
In the completed exercise, we can see how the Power Pivot data model allows us to build a Pivot- Table with summation fields and column fields from one table, row fields from a second table, and
a slicer from a third table, connecting the three tables via the State Abbr field in the relationships we defined.