Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Power excel 2016 with mrexcel Master Pivot Tables, Subtotals, Charts, VLOOKUP, IF, Data Analysis in Excel 2010–2013 (Bill Jelen) (z-lib.org).pdf
Скачиваний:
4
Добавлен:
14.08.2022
Размер:
49.75 Mб
Скачать

PART 3: WRANGLING DATA

303

 

 

Strategy: There are two common causes for this. The second most common cause is that you have a few blank cells in the revenue column. More likely: you are selecting all of columns A:H before creating a pivot table instead of selecting a single cell. This technique allows you to paste new records below the data later and you can simply Refresh. But this method is adding a million blank cells to the data range.

If you are selecting the entire column before creating the pivot table, the next topic will allow you to paste new records and have them automatically become part of the pivot table. If you start using a Table as the source, you won’t have to select the entire column anymore and you can simply checkmark Revenue.

Additional Details: Let’s say you want to add new records once a month. After pasting the records, you can use the Change Data Source button on the Analyze tab. Change the data address from ending in 564 to the new last row and click OK. This whole process takes less than 10 keystrokes and is far less hassle than have Revenue appear in the wrong spot.

Alternate Strategy: If the problem is caused by a few blank cells in the revenue column, follow these steps:

1. Select all of the cells that should be numeric. 2. Ctrl+H to display Find & Replace

3. Leave the top box blank. Type a 0 in the second box. Click Replace All.

3

Figure 775 People in my seminars convinced me this is easier than Go To Special, Blanks.

CONVERT YOUR DATA TO A TABLE BEFORE ADDING RECORDS

Problem: I have 100 new records to paste below the original data that is in the pivot table. How do I do that?

Strategy: There are two solutions. I recommend the second one.

Paste the new data below your original data. Select a cell in the pivot table. Choose the Change Data Source icon (see Figure 774 above).

Select a cell in the original data set. Press Ctrl+T to define the data as a table. Paste new data be- low the original data. The Data Source is automatically updated. Simply click the Refresh button to incorporate the new records.

The table feature began in Excel 2003 as a List. In Excel 2007, it was renamed to be a Table, creating confusion between the Data Table found in the What-If tools and the Format as Table command on the

Home tab.

The Table applies some interesting formatting. The Table adds Filter dropdowns. The Table makes it easier to enter formulas. But the most valuable feature of the table is to have the pivot table data range automatically grow as you add new rows to the underlying data.

Here is an example.

Currently, the pivot table uses rows 1:564 of data.

304

POWER EXCEL WITH MR EXCEL

 

 

Figure 776 Originally, the table used 564 rows.

Select a cell in that data and press Ctrl+T. Confirm the location of the table.

Figure 777 Convert the data to a table, even after the pivot exists.

When you paste 2015 Q1 data below the original data, the table definition automatically changes. The other thing that updates is the range used for the PivotTable Data Source. You no longer have to visit this dialog, as it is already updated.

Figure 778 That range automatically grew because the data is a table.

This still counts as a change to the underlying data, so you have to click the Refresh button to update the pivot table.

PART 3: WRANGLING DATA

 

305

 

 

 

CREATE A FLATTENED PIVOT TABLE FOR REUSE

Problem: Why would they put three different kinds of information in column A? Doesn’t this make pivot tables as silly as the person who created the bad data set back in “Add a Customer Number to Each Detail Record”?

 

Figure 779 Microsoft is mixing 3 fields in one column.

 

My goal is to use the pivot table to make a summary, then convert to values for use as a new data set. Hav-

 

ing three different fields in column A is really bad form.

 

Note: I’ve met one person who likes compact view. He has 15 fields in the Row Area of his report. Compact

 

layout allows that report to fit on a screen.

 

Strategy: It is very annoying that Microsoft made this new view be the default. Luckily, it is only a few

 

clicks to go back to the proper view.

 

1.

Select one cell in the pivot table.

 

2.

Choose the Design tab of the ribbon.

 

3

3.

Open the Report Layout dropdown.

4.

Change from Compact Form to Tabular Form.

 

 

5.

Open the Report Layout dropdown again and choose Repeat All Item Labels.

 

Figure 780 Eliminate blanks in the row area.

6. For each field in the Row Area except the last field, open the dropdown in the Row Area dropdown and choose Field Settings.

7. In the Field Settings dialog, choose None for Subtotals.

306

POWER EXCEL WITH MR EXCEL

 

 

Figure 781 Turn off the subtotals for the outer row fields.

8. On the Design tab, open the Grand Total dropdown and choose Off for Rows and Columns.

The result is a flattened pivot table, perfect for re-use as a new consolidated data set. Copy the pivot table and paste as values to a new worksheet.

Figure 782 Copy and Paste Values this pivot table for re-use.

REPLACE BLANKS IN A PIVOT TABLE WITH ZEROS

Problem: When I have no sales of a particular product in a particular region, Excel leaves those cells in the pivot table blank. This seems like a really bad idea. I’ve learned in this book that if my data has blanks instead of zeros, Excel will assume that a column is a text column. It is really ironic that Microsoft would dare to use a blank cell in the middle of numeric results.

Figure 783 Annoying and ironic that Excel uses blanks here.

Strategy: Follow these steps:

1. Right-click any cell in the pivot table and choose Pivot Table Options.

2. In the PivotTable Options dialog, select the Layout & Format tab and enter 0 in the For Empty Cells Show text box. Click OK.