The DGET function in Google Sheets is a powerful tool designed for extracting a single value from a range or array that resembles a database. This function uses a SQL-like syntax to perform queries, making it particularly useful for users who require specific data retrieval based on certain criteria.
Syntax
DGET(database, field, criteria)
- database: The range of cells that constitutes the database, including headers.
- field: The column label or number that contains the data you want to retrieve.
- criteria: The range that defines the conditions for selecting the data.
Example #1
DGET(A1:C10, "Salary", E1:E2)
Uses the database in the range A1:C10 to return the ‘Salary’ corresponding to criteria defined in the range E1:E2. For example, if the criteria is a specific employee’s name, it might return 50000.
Example #2
DGET(A1:C10, 2, F1:F2)
This function retrieves the value from the second column of the database range A1:C10 based on the criteria in F1:F2. If the criteria match a specific department, it could return 20, indicating the number of employees.
Example #3
DGET(B1:D10, "Department", G1:G2)
Applies the criteria in G1:G2 to the database range B1:D10 to fetch the corresponding ‘Department’. If the criteria encompass a specific employee status, it may return ‘Sales’.
Error handling
- VALUE!: This indicates that the specified field is not found in the database, possibly due to an incorrect label or index.
- NUM!: Occurs when the field is referenced by a column number that does not exist within the database.
- N/A: This error is shown when no records match the criteria specified in the criteria range.