0% found this document useful (0 votes)
40 views

Chapter 9: Tables and Worksheet Databases: Figure 9-13: This Table Shows Sales by Month and by Region

This document discusses advanced filtering of tables and worksheet databases in Excel. It provides instructions on how to set up a criteria range to specify filtering conditions. Advanced filtering allows for more complex criteria than standard filtering and can extract matching rows to a new location. The document uses a real estate listing database as an example and explains how to perform advanced filtering on this dataset.

Uploaded by

xdpablo328
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views

Chapter 9: Tables and Worksheet Databases: Figure 9-13: This Table Shows Sales by Month and by Region

This document discusses advanced filtering of tables and worksheet databases in Excel. It provides instructions on how to set up a criteria range to specify filtering conditions. Advanced filtering allows for more complex criteria than standard filtering and can extract matching rows to a new location. The document uses a real estate listing database as an example and explains how to perform advanced filtering on this dataset.

Uploaded by

xdpablo328
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Chapter 9: Tables and Worksheet Databases 255

Figure 9-13: This table shows sales by month and by region.

To change the name of a table, select any cell in the table, use the Table Name box in
the Table Tools➜Design➜Properties group. Or, you can use the Name Manager to
change the name of a table (Formulas➜Defined Names➜Name Manager).

Most of the time, your formulas will refer to a specific column in the table, rather than the entire
table. The following formula returns the sum of the data in the Sales column:

=SUM(Table2[Sales])

Notice that the column name is enclosed in square brackets. Again, the formula adjusts automati-
cally if you change the text in the column heading.

Keep in mind that the preceding formula does not adjust if table rows are hidden as a
result of filtering. SUBTOTAL and AGGREGATE are the only functions that change their
result to ignore hidden rows. To ignore filtered rows, use either of the following formulas:

=SUBTOTAL(109,Table2[Sales])
=AGGREGATE(9,1,Table2[Sales])

Even better, Excel provides some helpful assistance when you create a formula that refers to
data within a table. Figure 9-14 shows the Formula AutoComplete feature helping create a for-
mula by showing a list of the elements in the table.
Here’s another example that returns the sum of the January sales:

=SUMIF(Table2[Month],”Jan”,Table2[Sales])

For an explanation of the SUMIF worksheet function, refer to Chapter 7.

14_475362-ch09.indd 255 4/14/10 10:09 PM


256 Part II: Using Functions in Your Formulas

Figure 9-14: The Formula AutoComplete feature is useful when creating a formula that refers to data in a
table.

Using this structured table syntax is optional — you can use actual range references if you like.
For example, the following formula returns the same result as the preceding one:

=SUMIF(B3:B8,”Jan”,D3:D8)

To refer to a cell in the Total row of a table, use a formula like this:

=Table2[[#Totals],[Sales]]

If the Total row in Table2 is not displayed, the preceding formula returns a #REF error.
This formula returns the value in the Total row of the Sales column in Table2.
To count the total number of rows in Table2, use the following formula:

=ROWS(Table2[#All])

The preceding formula counts all rows, including the Header row and Total row. To count only
the data rows, use a formula like this:

=ROWS(Table2[#Data])

A formula that’s in the same row as a table can use a #This Row reference to refer to table data
that’s in the same row. For example, assume the following formula is in row 3, in a column out-
side Table2. The formula counts the number of entries in row 3 of Table2:

=COUNTA(Table2[@])

14_475362-ch09.indd 256 4/14/10 10:09 PM


Chapter 9: Tables and Worksheet Databases 257

You can also combine row and column references by nesting brackets and including multiple ref-
erences separated by commas. The following example returns Sales from the current row divided
by the total sales:

=Table2[[@],[Sales]]/Table2[[#Totals],[Sales]]

A formula like the preceding one is much easier to create if you use the pointing method.
Table 9-1 summarizes the row identifiers for table references and also describes which ranges
they represent.

Table 9-1: Table Row References

Row Identifier Description


#All Returns the range that includes the Header row, all data rows, and the Total row.
#Data Returns the range that includes the data rows but not the Header and Total rows.
#Headers Returns the range that includes the Header row only. Returns the #REF! error if
there is no Header row.
#Totals Returns the range that includes the Total row only. Returns the #REF! error if there
is no Total row.
@ Represents “this row.” Returns the range that is the intersection of the active row
and the table’s data rows. If the active row does not intersect with the table or it’s
the same row as the Header or Total row, the #VALUE! error is returned.

You can use the SUBTOTAL function to generate consecutive numbers for nonhidden
rows in a filtered table. The numbering will adjust as you apply filtering to hide or dis-
play rows. If your table has the field names in row 1, enter this formula in cell A2 and
then copy it down for each row in your table:

=SUBTOTAL(3,B$2:B2)

Converting a table to a worksheet database


If you need to convert a table back to a normal worksheet database, just select a cell in the table
and choose Table Tools➜Design➜Tools➜Convert To Range. The table style formatting remains
intact, but the range no longer functions as a table.
Formulas inside and outside the table that use structured table references are converted, so they
use range addresses rather than table items.

14_475362-ch09.indd 257 4/14/10 10:09 PM


258 Part II: Using Functions in Your Formulas

Filling in the Gaps


When you import data, you can end up with a worksheet that looks something like the one in
the accompanying figure. In this example, an entry in column A applies to several rows of data. If
you sort such a range, you can end up with a mess, and you won’t be able to tell who sold what.

When you have a small range, you can type the missing cell values manually. If your worksheet
database has hundreds of rows, though, you need a better way of filling in those cell values.
Here’s how:
1. Select the range (A3:A14 in this example).
2. Choose Home➜Editing➜Find & Select➜Go To Special to display the Go To Special
dialog box.
3. In the Go To Special dialog box, select the Blanks option.
4. Click OK to close the Go To Special dialog box.
5. In the Formula bar, type =, followed by the address of the first cell with an entry in the col-
umn (=A3 in this example), and then press Ctrl+Enter to copy that formula to all selected
cells.
6. Press Esc to cancel the selection.
7. Reselect the range and then choose Home➜Clipboard➜Paste Values.
Each blank cell in the column is filled with data from above.

Using Advanced Filtering


In many cases, standard filtering does the job just fine. If you run up against its limitations, you
need to use advanced filtering. Advanced filtering is much more flexible than standard filtering,
but it takes a bit of up-front work to use it. Advanced filtering provides you with the following
capabilities:

14_475362-ch09.indd 258 4/14/10 10:09 PM


Chapter 9: Tables and Worksheet Databases 259

h You can specify more complex filtering criteria.


h You can specify computed filtering criteria.
h You can extract a copy of the rows that meet the criteria and place them in another location.

You can use advanced filtering with a worksheet database or with a table.
The examples in this section use a real estate listing worksheet database (shown in Figure 9-15),
which has 125 records and 10 fields. This database contains an assortment of data types: values,
text strings, logical, and dates. The database occupies the range A8:H133. (Rows above the table
are used for the criteria range.)

Figure 9-15: This real estate listing database is used to demonstrate advanced filtering.

This workbook, named real estate database.xlsx, is available on the companion


CD-ROM.

Setting up a criteria range


Before you can use the advanced filtering feature, you must set up a criteria range, which is a
range on a worksheet that conforms to certain requirements. The criteria range holds the infor-
mation that Excel uses to filter the table. The criteria range must conform to the following
specifications:

h It must consist of at least two rows, and the first row must contain some or all field
names from the table. An exception to this is when you use computed criteria. Computed
criteria can use an empty Header row. (See the “Specifying computed criteria” section,
later in this chapter.)
h The other rows of the criteria range must consist of your filtering criteria.

14_475362-ch09.indd 259 4/14/10 10:09 PM

You might also like