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

255

 

 

Gotcha: Excel sorts the 65 Wal-Mart records as a single group. It does not perform any sorting within that group. The Wal-Mart detail records are in their original sequence. If you had wanted the detail records sorted descending, you would have originally sorted by Customer ascending, Revenue descending, then added the subtotals.

If you collapse back to the #2 group and sort by Customer, Excel is smart enough to leave the Grand Total at the bottom instead of sorting it into the G’s.

SELECT 100 COLUMNS IN SUBTOTALS

Problem: My data set is a hundred columns wide. In the

 

Subtotal dialog, I have to click 6 columns, then scroll, click

 

6 more columns, then scroll. It is incredibly tedious. Having

 

a “Select All” button would be incredibly helpful.

 

Strategy: Using the keyboard seems to be the fastest way.

 

If you press the spacebar, the selected row will toggle from

 

checked to unchecked. Scroll up, click on the words “Week

Figure 655 Individually click hundreds of

1” to select that row. Then, begin pressing spacebar, down

checkboxes.

arrow, spacebar, down arrow. It will still be tedious, but

 

faster than using the mouse and scrolling.

 

ENTER A GRAND TOTAL OF DATA MANUALLY SUBTOTALED

Problem: My manager doesn’t know the trick for doing automatic subtotals. He manually entered blank lines be- tween each customer and entered SUM formulas for each customer. How can I produce a grand total of all customers?

3

Figure 656 With 100 customers, the formula would be lengthy.

Strategy: Sum all of the cells and divide by 2 using =SUM(D2:D20)/2.

This method works! It is an old accounting trick (taught to me by an old accountant).

It is not intuitive, especially if you hated algebra.

Every number is in the Grand Total twice, once from the detail row and once from the manual totals.

Try it for yourself a few times, comparing the results to the method of using =D19+D13+D7. You will see that you get the same result.

256

POWER EXCEL WITH MR EXCEL

 

 

Gotcha: This method works only if all the customers are totaled. A manager who doesn’t know how to use subtotals might be the kind of manager who doesn’t total the customers with only one detail line. Below, line 9 will cause the total to not work.

Figure 658 If someone is manually adding totals, he might not add a redundant total for row 9.

Figure 657 Sum and divide by 2.

ADD OTHER TEXT TO THE SUBTOTAL LINES

Problem: My data set has account number in column A and a customer name in column B. When I subto- tal by account and collapse using the 2 Group & Outline button, I see only the Account numbers. While I have memorized that B4504 is Bell Canada, my manager cannot seem to remember this, so I need to add the customer name to the subtotal lines.

Figure 659 Add customer name to the subtotal rows.

Strategy: To add the customer name to the subtotal lines, you follow these steps:

1. Collapse the report by clicking the small 2 Group & Outline button above and to the left of cell A1. 2. Select all the blank cells in column B by using the mouse to drag from B6 down to the cell above the

Grand Total row. In doing so, you will select all the cells in the range B6:B136. 3. Type Ctrl+; to select the visible cells only. (Ctrl and Semicolon)

4. Note the row number of your first subtotal row. In this example, the first subtotal is row 6, and you will write a formula to copy the total from row 5. Change the cell reference in the following formula to point to the row above your first subtotal row: =“Total ”&B5. To enter a similar formula in every selected cell, press Ctrl+Enter.

PART 3: WRANGLING DATA

257

 

 

Figure 660 Add a customer name to each subtotal row.

Gotcha: Step 3 to select the visible cells only is important. If you fail to do this, you will overwrite all cus- tomers from row 6 to the bottom with Total Total Total.

If you see this, you need to immediately press Ctrl+Z to undo.

Gotcha: This trick gets the last customer name. If you need to get the first customer name from the group, you are going to have to use a clever trick and a three-line macro. Search YouTube for Learn Excel 712 for the details.

SUBTOTALS BY PRODUCT WITHIN REGION

Problem: I want to add subtotals by two fields, such as Product and Region.

Strategy: Adding subtotals by two fields seems easy, but there is a trick to it. You need to add subtotals to the least detailed field first. Here’s how it works:

1. Sort by product within region. Select a cell in the Product column. Click the AZ icon on the Data tab. Select a cell in Region. Click AZ.

2. Select Data, Subtotal and add a subtotal by Region. 3 3. Select Data, Subtotal again. Change Region to Product. Be sure to uncheck the Replace Current

Subtotals box.

Figure 661 Uncheck Replace Current Subtotals.

Results: You now have two sets of subtotals. There are now four Group & Outline buttons to the left of cell A1.

258

POWER EXCEL WITH MR EXCEL

 

 

Figure 662 Excel adds two levels of subtotals.

If you choose the 3 Group & Outline button, you will have totals by region and product.

Figure 663 #3 group and outline view.

If you choose the 2 Group & Outline button, you will have totals by region.

Additional Details: Here is why it is important to do the subtotals in the correct order: Say that your company sells three products. The Government region buys only product XYZ. You might have data that looks like the data below. Note that row 15 contains an XYZ record for the East, and row 16 contains an XYZ record for the Government region.

Figure 664 Same product, different regions are adjacent.

If you subtotal by product first, the XYZ products from the East and the Government regions will be trapped in one subtotal in row 25. This is an absolute mess.

Figure 665 Subtotal product first, and Excel has no idea that you will later subtotal by region.