DGET Function in Excel

Part 1: Introduce

Definition: The DGET function in Excel is a database function. It extracts a single record from a database that matches the specified conditions.

Purpose: The DGET function is used when you need to find a specific piece of data in a database based on multiple criteria.

Syntax & Arguments: The syntax for the DGET function in Excel is:

syntax
=DGET(database, field, criteria)

Explain the Arguments in the function:

  • database: The range of cells that make up the database. The database should include column headers.
  • field: The process will use the column to find and return the result. You can reference the area by its name (header name) or column number in the database.
  • criteria: The range of cells that contain the conditions you specify. It includes at least one column header and at least one cell below the column header for setting conditions for the corresponding column.

Return value: The DGET function will return the field value for the first record in the database that matches the criteria.

Remarks: If no records match the criteria, DGET we will produce an #VALUE! Error. If more than one record matches the criteria, DGET it will have a #NUM! Error.

Part 2: Examples

Example 1:

  • Purpose of illustration: Find the age of a specific employee named “John”.

  • Data tables and formulas:

ABC
1NameAgeFormula
2John32=DGET($A$1:$B$4, "Age", $E$1:$E$2)
3Anna27
4Rachel45

Where E1:E2 is the criteria range:

E
1Name
2John
  • Result table:
ABC
1NameAgeResult
2John3232
3Anna27#VALUE!
4Rachel45#VALUE!
  • Explanation: The formula uses the DGET Function to look for the name “John” in the “Name” column and then return his age from the “Age” column. The formula is inserted into the “Result” column.

Example 2:

  • Purpose of example: Find the sales of a product named “Product B” in the “East” region.

  • Data tables and formulas:

ABCD
1ProductRegionSalesFormula
2Product AWest1500=DGET($A$1:$C$4, "Sales", $E$1:$F$2)
3Product BEast2200
4Product CSouth1850

Where E1:F2 is the criteria range:

EF
1ProductRegion
2Product BEast
  • Result table:
ABCD
1ProductRegionSalesResult
2Product AWest1500#VALUE!
3Product BEast22002200
4Product CSouth1850#VALUE!
  • Explanation: The formula looks for “Product B” in the “East” region in the database, then returns its sales from the “Sales” column. The procedure is inserted into the “Result” column.

Example 3:

  • Purpose of example: Find an employee’s salary with the job title “Manager”.

  • Data tables and formulas:

ABCD
1EmployeeJobSalaryFormula
2AliceManager60000=DGET($A$1:$C$4, "Salary", $E$1:$F$2)
3BobAnalyst50000
4CharlieManager65000

Where E1:F2 is the criteria range:

EF
1EmployeeJob
2CharlieManager
  • Result table:
ABCD
1EmployeeJobSalaryResult
2AliceManager60000#VALUE!
3BobAnalyst50000#VALUE!
4CharlieManager6500065000
  • Explanation: The formula looks for an employee named “Charlie” with the job title “Manager”, then returns his salary from the “Salary” column. The formula is inserted into the “Result” column.

Example 4:

  • Purpose of example: Use DGET with the IF function to find the total profit of a product. If the gain is not available, return “Profit not available.”

  • Data tables and formulas:

ABCD
1ProductCostPriceFormula
2A1520=IF(DGET($A$1:$C$4, "Price", $E$1:$F$2)-DGET($A$1:$C$4, "Cost", $E$1:$F$2)=0,"Profit not available",DGET($A$1:$C$4, "Price", $E$1:$F$2)-DGET($A$1:$C$4, "Cost", $E$1:$F$2))
3B2025
4C2530

Where E1:F2 is the criteria range:

E
1Product
2A
  • Result table:
ABCD
1ProductCostPriceProfit
2A15205
3B2025#VALUE!
4C2530#VALUE!
  • Explanation: The formula calculates the profit for product A. If no profit data is found, it returns “Profit not available”.

Example 5:

  • Purpose of example: Use DGET with SUM to add all the sales for a specific region.

  • Data tables and formulas:

ABCD
1RegionSalesProductFormula
2East120A=SUM(DGET($A$1:$C$4, "Sales", $E$1:$F$2))
3West140B
4East150C

Where E1:F2 is the criteria range:

E
1Region
2East
  • Result table:
ABCD
1RegionSalesProductTotal
2East120A270
3West140B#VALUE!
4East150C270
  • Explanation: The formula sums up all the sales for the East region.

Example 6:

  • Purpose of illustration: Use DGET with VLOOKUP to find the price of a product.

  • Data tables and formulas:

ABCD
1ProductPriceStockFormula
2A1210=VLOOKUP("A", A2:C4, DGET($A$1:$B$4, "Price", $E$1:$F$2), FALSE)
3B1415
4C1620

Where E1:F2 is the criteria range:

E
1Product
2A
  • Result table:
ABCD
1ProductPriceStockVLookup
2A121012
3B1415#VALUE!
4C1620#VALUE!
  • Explanation: The formula uses VLOOKUP to find the price of product A.

Example 7:

  • Purpose of illustration: Use DGET with MAX to find the maximum sales value.

  • Data tables and formulas:

ABCD
1RegionSalesProductFormula
2East120A=MAX(DGET($A$1:$C$4, "Sales", $E$1:$F$2))
3West140B
4East150C

Where E1:F2 is the criteria range:

E
1Region
2East
  • Result table:
ABCD
1RegionSalesProductMax
2East120A150
3West140B#VALUE!
4East150C150
  • Explanation: The formula finds the maximum sales value for the East region.

Example 8:

  • Purpose of illustration: Use DGET with MIN to find the minimum sales value.

  • Data tables and formulas:

ABCD
1RegionSalesProductFormula
2East120A=MIN(DGET($A$1:$C$4, "Sales", $E$1:$F$2))
3West140B
4East150C

Where E1:F2 is the criteria range:

E
1Region
2East
  • Result table:
ABCD
1RegionSalesProductMin
2East120A120
3West140B#VALUE!
4East150C120
  • Explanation: The formula finds the minimum sales value for the East region.

Example 9:

  • Purpose of illustration: Use DGET with AVERAGE to find the average sales value.

  • Data tables and formulas:

ABCD
1RegionSalesProductFormula
2East120A=AVERAGE(DGET($A$1:$C$4, "Sales", $E$1:$F$2))
3West140B
4East150C

Where E1:F2 is the criteria range:

E
1Region
2East
  • Result table:
ABCD
1RegionSalesProductAvg
2East120A135
3West140B#VALUE!
4East150C135
  • Explanation: The formula finds the average sales value for the East region.

Example 10:

  • Purpose of example: Use DGET with COUNT to count the number of sales entries for a specific region.

  • Data tables and formulas:

ABCD
1RegionSalesProductFormula
2East120A=COUNT(DGET($A$1:$C$4, "Sales", $E$1:$F$2))
3West140B
4East150C

Where E1:F2 is the criteria range:

E
1Region
2East
  • Result table:
ABCD
1RegionSalesProductCount
2East120A2
3West140B#VALUE!
4East150C2
  • Explanation: The formula counts the number of sales entries for the East region.




Part 3: Tips and tricks

  1. Always ensure that your database range includes the column headers. Otherwise, the function might not work as expected.
  2. The field argument must be enclosed in double quotation marks if it is a text.
  3. If multiple records meet the criteria, DGET will return a #NUM! Error. To avoid this, ensure that only a single record matches your criteria.
  4. Suppose the DGET function returns the #VALUE! Error, this means that no rows meet the criteria you have specified.
  5. Consider using the Excel Advanced Filter feature and DGET if you have large datasets. It allows you to filter by multiple criteria and extract a list of records that meet complex conditions.
  6. Always check your data for duplicates or similar records, which might cause the DGET function to return errors.

Leave a Comment