Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
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б
Скачать
Figure 786 Collapse the Customer field.

PART 3: WRANGLING DATA

307

 

 

Figure 784 Add a zero to the For Empty Cells Show text box.

Results: Blanks in the values section of the pivot table are shown as zeros.

Additional Details: You can enter anything in the For Empty Cells Show text box. Some people like to use -- or n.a. in the formerly blank cells. Either works just as well as a zero.

 

COLLAPSE AND EXPAND PIVOT FIELDS

 

 

 

 

 

Problem: I will be using a pivot table projected on a screen during a sales forecasting meeting. I need

 

pivot tables that show products by region, but sometimes I need to see the customer detail for a product.

 

Strategy: You can solve this problem by building a pivot table with Region, Product, and Customer along

 

 

the row area.

3

 

 

 

 

Here’s how it works:

Figure 785 Start with Product, Region, and Customer.

1. Select one of the customer cells. In the Analyze tab of the ribbon, select Collapse Entire Field. Excel will hide all the customer rows.

2. Select a region cell and collapse that field as well.

Notice that each product has a plus sign button to the left of the field. When the meeting agenda moves to the DEF product, you can click the plus sign in A6 to see the region totals. You can continue collapsing sections as you are finished and then expanding the next sections.

308

POWER EXCEL WITH MR EXCEL

 

 

Additional Details: If you select the innermost row field (in this case, Customer) and select Expand

Entire Field, Excel assumes that you must need more detail for Customer. Because there is no additional detail in the pivot table, Excel will display the Show Detail dialog, allowing you to add a new field as the innermost row field.

Figure 787 Try to expand the innermost row field, and Excel will offer to add a new field.

SPECIFY A NUMBER FORMAT FOR A PIVOT TABLE FIELD

Problem: In a pivot table, a Values field tends to appear in a General format. This doesn’t always work for me. I might want thousands separators or even to show numbers in thousands. If I change the number format using the settings in the Home tab of the ribbon, the number format is lost after the next pivot table refresh.

Strategy: Microsoft has fixed this long-standing problem, but in a very subtle way.

In the figure below, you must select all of the Revenue cells, including the Grand Total Row and the Grand Total column. If you select the entire range, you can apply any number formatting from the Home tab and that formatting will stick.

Figure 788 Select all revenue cells before changing the format.

This never used to work! It was fixed in Excel 2010 but the fix was not documented. I accidentally discov- ered the fix in 2015 and even after I discovered the fix, I did not believe it would work. One of the program managers on the Excel team confirmed that the behavior changed recently.

Gotcha: One of the conventions in formatting tables says that you should include a currency symbol on only the first and total rows of a data set. There is no inherent way to do this with a pivot table. However, you can use the numeric formatting attached to the Sum of Revenue field to assign a non-currency format. Then you select the first row of cells and assign a currency format by pressing Ctrl+1 to display the Format

Cells dialog. This will work initially, but will be lost when you change the table.

PRESERVE COLUMN WIDTHS

Problem: I’ve nicely formatted my pivot table, including using narrow column widths.

PART 3: WRANGLING DATA

309

 

 

Figure 789 After manually applying column widths.

When I choose a new customer from the filter dropdown in B1, Excel changes all of my column widths.

Figure 790 Column widths change automatically.

Strategy: There is an option setting to prevent this behavior. Select any cell in the pivot table. Choose the

Options button at the left side of the Analyze ribbon tab. In the Layout and Format tab, uncheck the option for Autofit Column Widths On Update.

3

Figure 791 Uncheck Autofit checkbox.

Gotcha: After choosing this setting, you will have to fix your column widths one last time. The column widths don’t miraculously change back to the way they were.

Gotcha: When the column widths are not changing, you may not be able to see the customer selected in

B1. To solve this problem, add some fill formatting to C1:E1. Select B1:E1 and press Ctrl+One to display format cells. On the Alignment tab, open the Horizontal Alignment dropdown and choose Center Across Selection.

310

POWER EXCEL WITH MR EXCEL

 

 

Figure 792 Column widths stay as you set them.

SHOW YES/NO IN A PIVOT TABLE

Problem: I want to show Yes/No values in a pivot table. If the customer bought from us in a period, show Yes. If there were no sales, show No.

Figure 793 Instead of numbers, show Yes/No.

Strategy: Use a custom number format of “Yes”;”Credit”;”No”. Follow the steps in “Specifying a Number Format In a Pivot Table”. Once you are in the Format Cells dialog for the Sum of Revenue field, choose

Custom and type the code, including the quotes.

Figure 794 Show Yes for any positive value, No for zero.

Gotcha: This trick initially shows Yes for periods where there is a purchase, but leaves the other periods blank.

Figure 795 The Yes values appear.

To display the No values, you have to replace the blanks in the pivot table with a zero. See “Replace Blanks in a Pivot Table with Zeroes.”

Figure 796 Replace blanks with zero.