Click the PivotTable Tools Analyze tab and then in the Filter group, click the Insert
7. Click the PivotTable Tools Analyze tab and then in the Filter group, click the Insert
Slicer button.
Working with Advanced Charts and PivotTables
8. Select the State Abbr check box and then click OK .
9. Position and resize the slicer so that it covers all of cells L10:L26 .
10. On the Slicer Tools Options tab, in the Buttons group, use the Columns control to increase the number of columns in the Sales Rep slicer to six (6). Widen the slicer to make all data visible, if needed.
11. In the Sales Rep slicer, click the button for Amelia Earhart .
12. In the State Abbr slicer, click the button for AK . Hold down Ctrl and then click the buttons for GU , MH , and VI . Your worksheet should look like Figure 4-8.
Figure 4-8
A PivotTable with two slicers added
13. Click the Clear Filter buttons (the little funnel icons with the red “X” symbols in the top- right corner of each slicer) to clear the filters.
14. Select the worksheet PivotTable – Grouping . Next, we’ll add a timeline slicer to filter dates in a PivotTable.
15. Select any cell in the PivotTable and close the PivotTable Fields pane, if necessary. Click the Insert tab and then in the Filters group, click the Timeline button. In the Insert Timelines dialog box, select the Date check box and then click OK .
16. Position and resize the timeline so that it covers all of cells L3:R10 .
17. Click the MONTHS arrow near the top-right corner of the timeline and then select YEARS . Click the bar under 2016 and then drag the right handle to the right to include 2017 . The PivotTable adjusts to display only data from 2016 and 2017.
18. On the Timeline Tools Options tab, click the More button in the Timeline Styles group and then select Timeline Style Dark 2 . Your worksheet should resemble Figure 4-9.
Lesson 4
Figure 4-9
A PivotTable with a timeline slicer added
19. SAVE the workbook. PAUSE. LEAVE the workbook open to use in the next exercise.
Grouping Records in a PivotTable Normally, data in PivotTables gets grouped based on a hierarchy inherent in the data. For example
your data might contain country, state/province, and city fields. If you were grouping your data geographically, then you might have three levels of row headings—different cities being grouped together by state/province, and states/provinces being grouped by country.
Sometimes you will want to group rows or columns of data in a PivotTable by hand and show re- sults for aggregations of these custom groupings of rows and/or columns. By far the most common groupings are based on date. Excel offers several built-in tools to make grouping date data—by year, quarter, month, day, hour, minute and second—very easy.
STEP BY STEP
Group Records in a PivotTable
GET READY. LAUNCH Excel 2016 if it is not already open.
1. OPEN the
04 PivotTables Solution.xlsx workbook from the previous exercise, if you
closed it.
2. Select the worksheet PivotTable – Grouping if it isn’t already selected. NOTE: If you added the timeline slicer in the previous section, click the Clear Filter
button on the timeline so that the PivotTable will display data from all years.
3. Right-click any date in column A of the PivotTable and select Group from the shortcut menu.
4. Notice in the Grouping dialog box that the data runs from Jan 1, 2008 to Jan 1, 2018. (It’s worth noting that even though the highest date value in the Date column is 31-Dec-
17, Excel’s Grouping dialog box populates the “Ending At” field with 1/1/2018).
5. In the By list, select Months (only months) and then click OK .
6. Notice that even though we have ten years’ worth of data, our PivotTable now contains only twelve (12) rows of detail data running from Jan through Dec. This is a common mistake when grouping data by date! Our “Jan” row contains sales data from Jan 2008, Jan 2009, Jan 2010, through Jan 2017.
7. Right-click any of the cells containing a month heading and select Group .
8. Select both Years and Months and then click OK .
Working with Advanced Charts and PivotTables
9. Select cells B4:C4 .
10. Click the PivotTable Tools Analyze tab and then in the Group group, click the Group Selection button.
11. Change the text in cell B4 to Group D .
12. Repeat steps 9–11 for cells D5:E5 and change the value of D4 to Group G .
13. Repeat steps 9–11 for cells F5:G5 and change the value of F4 to Group T .
14. Repeat steps 9–11 for cells H5:I5 and change the value of H4 to Group W .
15. Click the PivotTable Tools Design tab and then in the Layout group, click the Subtotals button and then select the Show All Subtotals at Top of Group option.
16. Click the PivotTable Tools Analyze tab. In the Show group, make sure the +/- Buttons toggle button is turned on. (You want to see little [-] buttons beside the “Group D” and “Group G” labels and beside the years in column A.)
17. Click the little [-] buttons for Group D , Group G , 2008 , and 2009 . The specified product group columns and year group rows collapse. Compare your PivotTable to Figure 4-10.
Figure 4-10
A PivotTable with row and column groupings
18. Right-click any of the row header cells in column A (the ones containing a year or a month).
19. Point to Expand/Collapse and select the Collapse Entire Field option from the flyout menu.
20. SAVE the workbook. PAUSE. LEAVE the workbook open to use in the next exercise.
Take Note If you take a closer look at the Grouping dialog box for date grouping, you will notice that the option for grouping by week is not listed. If you need to group by week, then select Days (and only Days) as the grouping option. When you do, you will notice that a small spinner control at the bottom of the dialog box becomes enabled. Simply change the Number of Days to 7. To change the day of the week when the grouping begins, change the Starting At value at the top of the Grouping dialog box.