The Excel Database Functions are designed to assist you when working with an Excel database.
A database typically takes the form of a large table of data, where each row in the table stores an individual record. Each column in the spreadsheet table stores a different field (or type of information) for each record.
The database functions perform basic operations, such as count, max, min, etc, but they enable the user to specify criteria, so that the operation is performed on selected records only. Other records in the database are ignored.
The Excel Dget function returns a single value from a column of a database.
The record is selected via a set of one or more user-specified criteria.
The syntax of the Dget function is:
where the arguments are:
database | - | A range of cells containing the database. The top row of the database should specify the field names. | ||||
field | - |
The field (column) within the database, from which the record is to be selected. This can either be a field number, or can be the field name (i.e. the header in the top row of the database) encased in quotes (e.g. "Gender", "Subject", etc). |
||||
criteria | - |
A range of cells that contain the criteria, to specify which record should be returned. The range can include one or more criteria, which are presented as a field name in one cell and the condition for that field in the cell below. E.g.
|
Wildcards
The Excel Database functions allow the following wildcards to be used in text-related criteria:
? - matches any single character
* - matches any sequence of characters
(If you actually want to find the ? or * character, type the ~ symbol before this character in your search).
E.g. the condition "a*e" will match all cells containing a text string beginning with "a" and ending in "e".The criteria supplied beneath each field heading can be either:
Note that the Excel database functions are not case sensitive. So, for example, the criteria ="North" will be satisfied by cells containing the text "North" or "north".
A | B | C | D | |
---|---|---|---|---|
1 | Quarter | Area | Sales Rep. | Sales |
2 | 1 | North | Jeff | $223,000 |
3 | 1 | North | Chris | $125,000 |
4 | 1 | South | Carol | $456,000 |
5 | 1 | South | Tina | $289,000 |
6 | 2 | North | Jeff | $322,000 |
7 | 2 | North | Chris | $340,000 |
8 | 2 | South | Carol | $198,000 |
9 | 2 | South | Tina | $222,000 |
10 | 3 | North | Jeff | $310,000 |
11 | 3 | North | Chris | $250,000 |
12 | 3 | South | Carol | $460,000 |
13 | 3 | South | Tina | $395,000 |
14 | 4 | North | Jeff | $261,000 |
15 | 4 | North | Chris | $389,000 |
16 | 4 | South | Carol | $305,000 |
17 | 4 | South | Tina | $188,000 |
The following examples use the above simple database on the right, which stores the sales figures for four sales representatives, for each quarter of the sales year.
In the example below, the Dget function is used to return the sales figure for Sales Rep. "Tina" in quarter 4. The criteria are specified in cells F1 - G2 and the Dget formula is shown in cell F3:
F | G | |
---|---|---|
1 | Sales Rep. | Quarter |
2 | Tina | 4 |
3 | =DGET( A1:D17, "Sales", F1:G2 ) |
The above Dget function finds the record in row 17, and returns the value from the "Sales" column. Therefore, the function returns the value $188,000.
Note that, in the above example, instead of typing in "Sales" for the field argument, we could have simply used the number 4 (to denote the 4th column of the database).
In the example below, we attempt to use the Dget function to extract the Sales figure for the South area in quarter 4.
F | G | |
---|---|---|
1 | Area | Quarter |
2 | South | 4 |
3 | =DGET( A1:D17, "Sales", F1:G2 ) |
The criteria arguments for the above Dget function are satisfied by two rows of the database - rows 16 & 17. However, the Dget function requires that only one record satisfies the criteria. The function therefore returns the Excel error #NUM!.
In the example below, the Dget function is used to find the name of the sales rep. who obtained the maximum quarterly sales figure.
F | G | |
---|---|---|
1 | Sales | |
2 | =MAX( D2:D17 ) | |
3 | =DGET( A1:D17, "Sales Rep.", F1:F2 ) |
In the above criteria, the Max function (in cell F2) returns the maximum Sales value of $460,000. The Dget function then finds the record in row 12, that contains this value, and returns the "Sales Rep." for that record - i.e. returns the text "Carol".
For further examples of the Excel Dget function, see the Microsoft Office website.
If you get an error from the Excel Dget function this is likely to be one of the following:
#NUM! | - | Produced if more than one record in the supplied database satisfies the supplied criteria. |
#VALUE! | - | Produced if no records in the supplied database satisfy the supplied criteria. |