Thursday 10 July 2014

Excel DGET Function

Microsoft Excel DGET Function

Basic Description

The Excel Dget function returns the value contained in a field (column) of a single record in a database.
The record is selected via a set of one or more user-specified criteria.
The syntax of the function is :
DGET( database, field, criteria )
where the arguments are shown in the following table:

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 (ie. the header in the top row of the database) encased in quotes (eg. "Gender", "Subject", etc)
criteria-A range of cells that contain the criteria, to specify which records should be included in the calculation.
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.
eg.
SubjectAge
Math>8

Wildcards
You can also use the following wildcards in text-related criteria:
?    -    matches any single character
*    -    matches any sequence of characters
if you do actually want to find the ? or * character, type the ~ symbol before this character in your search.
eg. 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:
-a numeric value (including an integer, decimal, date, time, or logical value) (eg. 10, 01/01/2011, FALSE)
or
-a text string (eg. "Text", "Thursday")
or
-an expression (eg. ">8", "<>0")

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".

Excel Dget Function Examples

ABCD
1QuarterAreaSales Rep.Sales
21NorthJeff$223,000
31NorthChris$125,000
41SouthCarol$456,000
51SouthTina$289,000
62NorthJeff$322,000
72NorthChris$340,000
82SouthCarol$198,000
92SouthTina$222,000
103NorthJeff$310,000
113NorthChris$250,000
123SouthCarol$460,000
133SouthTina$395,000
144NorthJeff$261,000
154NorthChris$389,000
164SouthCarol$305,000
174SouthTina$188,000
The following examples use the simple database on the right, which stores the sales figures for four sales representatives, for each quarter of the sales year.

Example 1

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:
FG
1Sales Rep.Quarter
2Tina4
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).

Example 2

In the example below, we attempt to use the Dget function to extract the Sales figure for the South area in quarter 4.
FG
1AreaQuarter
2South4
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 is selected by the criteria. The function therefore returns the Excel error #NUM!.

Example 3

In the example below, the Dget function is used to find the name of the sales rep. who obtained the maximum quarterly sales figure.
FG
1Sales
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 - ie. returns the text "Carol".

Further examples of the Excel Dget function can be found on the Microsoft Office website.

Dget Function Errors

If you get an error from the Excel Dget function this is likely to be one of the following :
Common Errors
#NUM!-Produced if more than one record in the database satisfies the supplied criteria.
#VALUE!-Produced if no records in the database satisfy the supplied criteria.

No comments:

Post a Comment