HomeGoogle DocsSpreadsheetHow to Use the Function Dget in Google Sheets

How to Use the Function Dget in Google Sheets

Published on

The Dget is the one and only Database function in Google Sheets that can use for vertical lookup. In Google Sheets, all Database functions are for Aggregation except the Dget. You can use the function Dget in Google Sheets in vertical lookup and return values from multiple columns, not rows.

If you want to use Dget to get data, you should make sure that your dataset complies with the following basic database requirements.

1. The data should be in tabular form and the top row of your data should contain field labels.

2. The table should not contain any duplicates. If there are duplicates, you should remove that by using the Unique or SORT function that you can use within the DGET. Because if there are multiple matches, Dget will return an error. This part also you can learn in this Google Sheets tutorial.

3. There shouldn’t be any merged cells in between your data range.

In other words, you can use the function Dget in Google Sheets in a structured dataset.

How to Use the Dget Function in Google Sheets

Syntax:

DGET(database, field, criteria)

This is the common syntax for all the database functions in Google Sheets like Dsum, Dproduct, Dcount, etc. Only the function name changes.

Details about the Function Arguments:

Note: No need to pay much attention to the arguments. You can learn the usage of the function Dget in Google Sheets from my examples itself.

Database:

The database is the array or range containing the data to consider. It should comply with the three points mentioned below the second paragraph of this tutorial.

Field:

The field is the field label or column number of the column which contains the values to be extracted and operated on.

If you know the use of Vlookup, you can compare the field in Dget with the Index Number in Vlookup.

Criteria:

The field is an array or range containing zero, one or more criteria by which to filter the database values before operating. In Vlookup terms, the criteria in Dget function are the search keys in Vlookup.

Examples of Google Sheets Dget Function

The below is a basic example of the use of the Dget function in Google Sheets.

Examples of Google Sheets Dget Function

See the Dget formula in cell F3. In this formula, the range A2:C6 is the database, F2 is the field and E2:E3 is the criteria.

What does this Dget formula do?

Since the field name (F2) in this formula is “price”, it returns a value from column C, which contains the label “price”, based on the criterion. The criterion is the “brand” name “C” in column A.

The above is the normal type use of the functions starting with the letter D in Google Sheets.

In such functions, the field and criteria are used as cell references and that’s the beauty of these functions.

But you can use the filed and criteria within the database formulas too. Here is an example.

=dget(A2:C6,"price",{"brand";"C"})

This Google Sheets Dget formula also returns the value 40 from the third column, which is the “price” field. Just like Vlookup, here also, you can replace the field label with the column number.

=dget(A2:C6,3,{"brand";"C"})

Vlookup Instead of Dget in Sheets

Let me give you one Vlookup example formula that replaces the above Dget formula.

=vlookup("C",A2:C6,3,false)

This formula can produce the same result that our above Dget formula provides.

To make you understand the difference I am trying to compare the arguments of Vlookup and Dget.

The range in both formulas is the same, i.e., A2:C6.

The search key/lookup key is “C” in Vlookup. In Google Sheets Dget formula, it’s called the criteria. There you should include the field label of the column containing the criteria.

In Vlookup the number 3 (3rd column) is the index column. From this column, the formula extracts the matching value. In Dget also the usage is the same.

How to Extract Multiple Column Values in Dget in Google Sheets

In Vlookup you can use multiple column index numbers. It’s possible in Dget too.

Dget Formula with Multiple Fields.

=ArrayFormula(dget(A2:C6,{2,3},{"brand";"C"}))

Vlookup Formula with Multiple Index Numbers.

=ArrayFormula(vlookup("C",A2:C6,{2,3},false))

Both of these formulas return the same result. See the below screenshot to understand the Dget formula clearly.

Multiple Fields in Google Sheets Dget Function

This example proves that Google Sheets Dget function can return multiple column outputs.

Similar: Multiple Values Using Vlookup in Google Sheets is Possible [How to]

How to Use Multiple Criteria in Dget in Google Sheets

Just like all other Database functions in Google Sheets, you can easily use multiple criteria in Dget if the criteria are used as cell references.

dget with multiple criteria

If you use the multiple criteria in Dget within the formula, then there is a tweak using Transpose. Thanks, Jan for sharing that tip via Comment.

=ArrayFormula(dget(A2:C6,3,transpose({"brand","C";"size","M"})))

Similar: How to Use VLOOKUP with Multiple Criteria in Google Sheets [Solved]

How to Handle Duplicates in Dget in Sheets

The multiple occurrences of items in the criteria field can cause an error in the Dget function output. In such cases, you can use the Unique or SORTN function to remove duplicates.

The generic formula would be like this. I am not going into any detail as it’s the rare case. In such cases better use Vlookup.

=DGET(unique(database), field, criteria)

Pros and Cons

Pros:

  1. The Google Sheets Dget function is a database function. So if you have a structured data you can use it for vertical lookup. It can improve your Spreadsheet performance compared to Vlookup. It’s my point of view. I have not seen any official documentation regarding this.
  2. In Dget function the Criteria (lookup column) position is not important. It can be from any column. But in Vlookup it should be the first column. But anyways, you can tweak that in Vlookup.

Cons:

  1. The Dget formula returns #VALUE! error if the criterion doesn’t match. So you should wrap Google Sheets Dget formula with an Iferror.
  2. You are not allowed to use multiple criteria in Dget function which is possible in Vlookup. Corrected this. Please see the details under the subtitle above “How to Use Multiple Criteria in Dget in Google Sheets”.
  3. Duplicates in the criteria/lookup column are not allowed. This causes #NUM! error in DGET.
Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

SORT and SORTBY – Excel Vs Google Sheets

While Excel offers the SORT and SORTBY functions for sorting a table, Google Sheets...

Get Top N Values Using Excel’s FILTER Function

When using the FILTER function in Excel to extract the top N values, it's...

XLOOKUP in Excel: Working with Visible Rows in a Table

In Excel, the XLOOKUP function isn't inherently designed to exclusively work with visible rows;...

SUMPRODUCT Differences: Excel vs. Google Sheets

The core purpose of the SUMPRODUCT function remains consistent across both Excel and Google...

More like this

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

Analyzing Column A Between Non-Adjacent Values in Column B: Google Sheets

This tutorial addresses a common scenario encountered in Google Sheets: how to sum, average,...

11 COMMENTS

  1. Hi Prashanth,

    Is there a way to use DGET to continue to run down a column as data continues to come in?

    I need this to run continuously:

    =DGET('Settlement Data'!$A$1:$H,"Revenue",{"WE","Ranch","Program";N3,O3,P3})

    I tried this but I get an error for more than one match found:

    =ArrayFormula(if(isblank(N3:N),"",DGET('Settlement Data'!$A$1:$H,"Revenue",{"WE","Ranch","Program";N3:N,O3:O,P3:P})))

    Any Ideas?

  2. Hi Prashanth,

    I need to get the Database in Sheet1 (UPC, Item No., Price).

    In Sheet2, I have to match the database items and get item no. Sheet 2 having (Upc, Product Description).

    But the thing is, the sheet2 UPC is comma-separated values given. Need to extract the UPC and match it with Sheet1 UPC. I get the Individual UPC and match it with INDEX & MATCH function. But I could not able to get the comma-separated UPC in Sheet 2.

    I request you to kindly give a solution to get this done.

    It will very helpful.

    • Hi, Saravanan,

      In Sheet2!C2 (as Sheet2!A1:C1 may contain field labels), enter the following formula and drag-down.

      =textjoin(", ",true,iferror(ArrayFormula(vlookup(trim(split(A2,",")),Sheet1!$A$1:$B$5,2,0))))

      • Thanks, Prasanth for your quick response. I used this in google sheet. But I get #N/A. For your reference, I shared the google sheet for your kind reference. Please look and give the solution to fix.

        • Hi, Saravanan,

          Updated your sheet with my formula.

          You have missed a comma after the TRUE argument in the TEXTJOIN part.

          Further, I have converted the split text values back to numeric using the VALUE function.

          Seems, it works now!

  3. I was recently confronted with a problem.

    Where “B-BOX” and “B-BOX PRO” are considered duplicates in this formula.

    Is there a way to resolve this?

  4. Contrary to the Con #2, it is actually possible to use multiple criteria in the Sheets database functions such as DGET, separated by a semicolon.
    Syntax examples:
    =DGET(database,"field",TRANSPOSE({"Country","Switzerland";"City","Zurich"}))
    =DGET(database,"field",TRANSPOSE({"Country","Switzerland","Switzerland";"City","Zurich","Geneva"}))

    • Hi, Jan,

      Thanks for pointing out the mistake!

      I was aware of how to use the multiple criteria as a cell reference in Dget. But new to the use of criteria within formula as you have pointed out at least at the time of writing this post (a few months back).

      Updated the post and given due credit to you.

      Have a nice day!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.