Professional Documents
Culture Documents
information in a database
View products that this article applies to.
Article ID : 282851
Revision : 6.2
SUMMARY
This article describes how to use Microsoft Excel tables to analyze information contained in a
database.
Back to the top
MORE INFORMATION
You can use database functions in one-input and two-input tables to analyze values obtained
from a database, by using both comparison and computed criteria.
Back to the top
Comparison Criteria
Comparison criteria are the most commonly used criteria to extract or analyze information
from a Microsoft Excel database. The value that you place under the column heading in your
criteria range is compared against the records in your database. If a record matches that value,
the record is extracted or included in the group of records to be analyzed by the database
functions.
To create a sample database and a sample criteria range, follow these steps:
1. Open a new workbook.
2. Type the following information in cells A1:C25 of a new worksheet:
| A | B | C ---|--------------|---------|-------- 1 | Type of
Soda |Month |Consumed 2 | Pepup |January | 946 3 | Diet Pepup |
January | 762 4 | Colo |January | 224 5 | Diet Colo |January |
1 6 | Splash |January | 715 7 | Diet Splash |January | 506 8 |
Lime-Up |January | 354 9 | Diet Lime-Up |January | 542 10|
Pepup |February | 910 11| Diet Pepup |February | 894 12| Colo |
February | 926 13| Diet Colo |February | 471 14| Splash |
February | 493 15| Diet Splash |February | 276 16| Lime-Up |
February | 45 17| Diet Lime-Up |February | 301 18| Pepup |March
| 840 19| Diet Pepup |March | 442 20| Colo |March | 409 21|
Diet Colo |March | 205 22| Splash |March | 109 23| Diet Splash
|March | 263 24| Lime-Up |March | 603 25| Diet Lime-Up |March |
555
In a One-Input Table
To find the cost of soda consumed per type the entire period, create a one-input table that
uses the data from the database:
1. In cells E5:E12, type the different kinds of soda. (Because you enter this variable data in a
column, this is a column input table).
NOTE: You can copy the types from the database and paste them into the cells.
2. In cell F4, type the formula:
=DSUM(Database,"Consumed",Criteria)*0.45
NOTE: This formula adds all the consumed sodas in the database that match the specified
criteria, and multiplies the result by 45 cents (the cost per can).
3. Select cells E4:F12.
4. On the Data menu, click Table.
5. In the Column Input Cell box, type E2.
NOTE: E2 is the cell in the criteria range where you would type the name of a specific type of
soda. Because you want to substitute different types of soda to calculate the expense for each
type, leave cell E2 blank in the actual criteria. The table automatically (internally) substitutes
each soda type that is listed in the table (E4:E12) into cell E2, and calculates the formula
based on that criteria.
The value displayed in cell F4 is a number format. To duplicate this value, follow these steps:
1. Select cell F4.
2. On the Format menu, click Cells.
3. Click the Number tab.
4. In the Category list, click Custom.
5. In the Type box, type "Money Spent on Beverages" (with the quotation marks).
6. Click OK.
In a Two-Input Table
For the following example, use the sample database and criteria that you created earlier. To
create a two-input table and use it to find the cost of soda consumed per type per month, follow
these steps:
1. In cells E15:E22, type the different types of soda. (This represents the column input.)
NOTE: You can copy the types from the database and paste them into the cells.
2. Type January in cell F14, type February in cell G14, and type March in cell H14.
3. In cell E14, type the formula:
=DSUM(Database,"Consumed",Criteria)*0.45
NOTE: This formula adds all the consumed sodas in the database based on the criteria, and
multiplies the total by 45 cents (cost per can).
4. Select cells E14:H22.
5. On the Data menu, click Table.
6. In the Row Input Cell box, type F2. In the Column Input Cell box, type E2.
NOTE: Because you want to calculate the expenses for each type of soda for each month, and
do not want to limit your expense analysis to one particular month, leave F2 blank in the
defined criteria range. F2 is the cell in the criteria range where you would type the name of a
specific month. The table automatically (internally) substitutes each month that is listed in the
table (F14:H14) into cell F2, and calculates the formula based on that month.
Because you want to calculate the expense for each type of soda, leave E2 blank in the actual
criteria. E2 is the cell in the criteria range where you would type the name of a specific type of
soda. For example, if you wanted to calculate the expense for your diet sodas, you would
place the word "diet" in cell E2. The table automatically (internally) substitutes each soda type
that is listed in the table (E15:E22) into cell E2 and calculates the formula based on that type.
The value displayed in cell E14 is a number format. To duplicate this value, follow these steps:
1. Select cell E14.
2. On the Format menu, click Cells.
3. Click the Number tab.
4. In the Category list, click Custom.
5. In the Type box, type "Cost per Month" (with the quotation marks).
6. Click OK.
Back to the top
Computed Criteria
You can also use computed criteria in one-input and two-input tables to obtain and analyze
values from a database. Computed criteria use a formula to extract or obtain values for
analysis.
| A | B | C ---|-----------|---------|------------ 1 | Product #
|Date |Amount Sold 2 | 9865| 1/2/90| 91 3 | 9870| 1/12/90| 94 4 |
9875| 1/22/90| 76 5 | 9880| 2/1/90| 22 6 | 9865| 2/11/90| 82 7 |
9870| 2/21/90| 71 8 | 9870| 3/3/90| 50 9 | 9865| 3/13/90| 35 10|
9880| 3/23/90| 54 11| 9875| 4/2/90| 80 12| 9865| 4/12/90| 33 13|
9880| 4/22/90| 83 14| 9875| 5/2/90| 62 15| 9870| 5/12/90| 15
Follow these steps to define the database name and set a criteria:
1. Select cells A1:C15.
2. On the Insert menu, point to Name, and then click Define.
3. Type Database, and then click OK.
4. Select cells E1:H2.
5. On the Insert menu, point to Name, and then click Define.
6. Type Criteria, and then click OK.
| E | F | G | H
---|-----------|-----|-------------|--------------------- 1 |
Product # |Date |Amount Sold | 2 | | | |=MONTH(B2)=MONTH($H$3)
The formula =MONTH(B2)=MONTH($H$3) returns a value of either TRUE
or FALSE, which is displayed in H2: | E | F | G | H
---|-----------|-----|-------------|--------- 1 |Product # |Date
|Amount Sold | 2 | TRUE
In a One-Input Table
If you want to find out how many items were sold each month, how many days a sale was
made, and the maximum number of items sold on one day in each month, create a one-input
table from this data, as follows:
1. Type the following data in cells E6:E10:
NOTE: If you only want the name of the month to be displayed in the table (as in the
following example), change the number format of cells E6:E10. To do this, click Cells on the
Format menu, click Custom in the Category list, and then type mmmm in the Type box.
With this format, E6 is displayed as January, E7 is displayed as February, and so on.
2. In cell F5, type the formula:
=DSUM(Database,"Amount Sold",Criteria)
3. In cell G5, type the formula:
=DCOUNT(Database,,Criteria)
4. In cell H5, type the formula:
=DMAX(Database,"Amount Sold",Criteria)
5. Select cells E5:H10.
6. On the Data menu, click Table.
7. In the Column Input Cell box, type H3.
NOTE: Cell H2 contains the formula =MONTH(B2)=MONTH($H$3). This formula checks to see
if the month in the first record of the Date field (B2) equals the month of cell H3 (cell H3 is
the column input cell). The table automatically (internally) substitutes each month listed in
the table (E5:E10) into cell H3, and calculates the formulas based on that month.
The values displayed in cells F5:H5 are number formats. To duplicate these values, follow these
steps:
1. Select cell F5.
2. On the Format menu, click Cells.
3. Click the Number tab.
4. In the Category list, click Custom.
5. In the Type box, type "Total Amount" (with the quotation marks).
6. Click OK.
7. Repeat steps 1-5 with cells G5 and H5. In step 5, type the formats as "# of Entries" and
"Max Entry", respectively (with the quotation marks).
In a Two-Input Table
If you want to find how many items were sold each month for each product number, you can
create a two-input table from this data, as follows:
1. Type the following data in cells E13:E17 of column E:
NOTE: If you want only the name of the month to be displayed in the table (as in the
following example), change the number format of cells E13:E17 to mmmm. To do this, click
Cells on the Format menu, click Custom, and then type mmmm in the Type box. With this
format, E13 is displayed as January, E14 is displayed as February, and so on.
2. Type the following product numbers in cells F12:I12 of row 12:
NOTE: Because you want the total number of each product sold broken down by each month,
leave E2 blank in the defined criteria range. E2 is the cell in the criteria range where you
would type a specific product number. The table automatically (internally) substitutes each
product number in the table (F12:I12) into cell E2, and calculates the formula based on that
product.
Cell H2 contains the formula =MONTH(B2)=MONTH($H$3). This formula checks to see if the
month in the first record of the Date field (B2) equals the month of cell H3, which is the
column input cell. Remember, the table automatically (internally) substitutes each month in
the table (E13:E17) into cell H3, and calculates the formulas based on that month.
REFERENCES
For more information about how to use data tables, click the following article number to view
the article in the Microsoft Knowledge Base:
282852 An overview of data tables in Microsoft Excel
282855 How to create and use one-input data tables in Microsoft Excel
282856 How to create and use two-input data tables in Microsoft Excel
Back to the top