# Section 20.1. Summary Tables Revisited

20.1. Summary Tables Revisited

When you analyze large amounts of data, you can look at the same information in many different ways. How you organize and group the data often determines whether you find or overlook important trends.

Note:

Tip: In Chapter 14, you saw how to tame large tables of data with features like grouping and outlining. Pivot tables offer another approachthey're a little more work to set up, but they give you much more flexibility in rearranging your tables and calculating different summary information on the fly.

For example, consider the small table of information shown in Figure 20-1. This table lists all the customers of a small business, along with information about their gender, the city they live in, and their level of education. Looking at this table, an important question comes to mind: is there a relationship between these different pieces of information and the amount of money a customer spends?

 Figure 20-1. In this example, there are only 10 records, so patterns aren't difficult to spot. However, if you extended this list to hundreds or thousands of rows, you would definitely need a summary table to spot any relationships that might exist.

To look for trends and patterns in the customer list, it helps to build a summary table a table that tallies key amounts, like the average amount spent for a customer in a specific city, education level, or gender. However, there are several potentially important relationships, and, therefore, several types of summary tables that you could create. Pivot tables are the perfect tool because they give you almost unlimited flexibility when you want to figure out different relationships. But before you learn about how to build pivot tables, it first helps to understand what life is like in Excel without thembecause only then can you see why pivot tables make sense and decide whether you need them in one of your own workbooks.

#### 20.1.1. Life Without Pivot Tables

The most basic way to calculate summary information is to use the SUMIF( ) and COUNTIF( ) functions described in Chapter 12. For example, to find the average annual purchases for an individual in New York, you first calculate the total purchases made by all New York customers. Here's the formula you need:

` =SUMIF(C2:C11, "New York", E2:E11) `

This formula scans the City column (C2 to C11) looking for the text. Every time it finds a match, it adds the corresponding purchase amount from the Annual Purchases column (E2 to E11).

Once you have the total purchases, you need to divide this figure by the number of New York customers. To count the number of New York customers, you use the COUNTIF( ) function.

Here's the revised formula for finding the average annual purchase amount:

` =SUMIF(C2:C11, "New York", E2:E11)/COUNTIF(C2:C11, "New York") `

Finally, you can make this formula more generic so that you don't need to create a new version for each city. Instead, change the formula so that it retrieves the text it should match (the city's name ) from a cell just to the left of where you're going to place the formula. (As shown in Figure 20-2, this group of "city" formulas resides in cells B15, B16, and B17.) Then, you can copy your formula into multiple rows. The formula won't change, but, in each row, the cell on the left will have a different value, instructing the formula to search for customers in a different city.

 Figure 20-2. These three summary tables retrieve their data from the table shown in Figure 20-1 and calculate average purchases by grouping the customers into different categories. The purchase-by-city summary shows that there isn't a significant amount of difference based on location (although Seattle customers tend to spend a little less). The purchase-by-education summary demonstrates a dramatic difference, with less educated individuals making smaller purchases. Finally, the purchase-by-gender comparison turns up no variance at all.

Here's the perfected formula:

` =SUMIF(\$C:\$C, A15, \$E:\$E)/COUNTIF(\$C:\$C, A15) `

Note that in this formula, all the search ranges are fixed as absolute references using the dollar sign (\$). The search text isn't fixedthat way, when you copy the formula to a new row, the formula uses the search text on that row.

Figure 20-2 shows several summary tables that use this technique for calculating averages.

In this example, building each table isn't terribly difficult, but the situation clearly becomes more tedious the more ways you want to compare the same data. It's not difficult to imagine a more realistic scenario where you might want to look at customer purchases based on age bracket , income level, and the answers to different customer survey questions. To get the full picture with this information, you would need to build each table from scratch.

In fact, in some of these more complex scenarios, you might need to group and then subgroup your information. Figure 20-3 shows a more advanced example of a table that calculates the variance in average annual purchases by city, and then shows the subdivided totals in each city by gender.

 Figure 20-3. This summary table is a little more advanced. It groups and then subgroups data, which lets you find hidden trends. For example, in this case it identifies New York females as the best purchasers . Of course, there are far too few rows in this example for the results to be truly persuasive. In a table with thousands of rows, however, a grouped and subgrouped breakdown becomes much more meaningful.

The summary in Figure 20-3 performs a two-dimensional comparison. In other words, it compares two different groupingsone by city in different rows, and one by gender in different columns . This is a step up from the one-dimensional summary tables you saw earlier, but it's also far more difficult to correctly calculate. You could use the SUMPRODUCT( ) function (Section 12.1.4), or create the table in two steps (first grouping the records by city, and then totaling them by gender). In either case, life gets much more complicated, and that's when pivot tables really shine .

#### 20.1.2. Life with Pivot Tables

With a pivot table, you can create summary tables like the ones shown in Figures Figure 20-2 and Figure 20-3 just by choosing the columns you want to compare. And once you've built your summary, you don't need to stick with itinstead, you can transform a purchase-by-education table into a purchase-by-city table just by dragging and dropping. You can even drill down into the details, apply filter criteria, and apply advanced subtotaling calculations. The following sections describe all of these techniques.

 Up To Speed How Pivot Tables Compare to Grouping and Data Lists Before going any further, why not get your head around how pivot tables fit in with other Excel features that you've already seen? In Chapter 14, you learned about two techniques for grouping and organizing data. These include: Grouping . Excel's grouping tools lets you collapse detailed information in a table so that only the summary information remains. This technique is the perfect solution when you have a worksheet that contains both detail and summary information and you want to make it more manageable. However, you still need to write all the summary formulas and decide how you want to organize the information. Automatic subtotaling . Automatic subtotaling generates subtotals for a data list by grouping it according to a column that you choose. Automatic subtotaling is a good technique for building a quick-and-dirty summary report, but it doesn't provide a lot of flexibility. It also breaks up the structure of your list so that you can't effectively edit it any longer. Compared to either of these features, pivot tables are more flexible and more dynamic. A single pivot table can group and subtotal the same list in different waysall you need to do is drag and drop your columns. Thanks to this flexibility, pivot tables are a much more flexible tool for analyzing your information and discovering hidden relationships.

Excel 2010: The Missing Manual
ISBN: 1449382355
EAN: 2147483647
Year: 2003
Pages: 185

Similar book on Amazon