HomeGoogle DocsSpreadsheetExact Match in Database Functions in Google Sheets - How-To

Exact Match in Database Functions in Google Sheets – How-To

Published on

Exact Match of a text string(s) is possible in database functions like DSUM, DGET, DAVERAGE, DPRODUCT, DCOUNT, etc. in Google Sheets.

It is very important to know how to use an exact (accurate) match criterion in database functions aka D’ Functions in Google Sheets.

Actually it’s very simple! I’ll give you a few examples. Before going to the examples, you must know what impact an exact match can bring into the outputs of the database functions.

If there are two or more similar values matching the criterion in the database field (criteria field), the DGET function would return #NUM! error whereas most of the other database functions would return an inaccurate result.

Bit confusing, right? You will get a better idea about the same from my following database function examples.

Exact Match in DGET Database Function in Google Sheets

DGET doesn’t mean for aggregating values. It’s a lookup type (database) function.

Similar to the ‘index’ column in a Vlookup formula, the DGET returns the value of the ‘field’ specified in the second argument.

In other words, both ‘index’ (Vlookup) and ‘field’ (Database functions) refer to the same.

Syntax: DGET(database, field, criteria)
Syntax: VLOOKUP(search_key, range, index, [is_sorted])

If there are multiple matches or no match, the DGET formula would return #NUM! error. But the Vlookup will return #N/A error when there is no match and no issue with multiple matches.

Let’s leave that aside and concentrate on the exact match in database functions in Google Sheets. See the following DGET formula in cell F3.

=dget(A2:C8,3,E2:E3)
#NUM! Error in DGET in Docs Sheets

The formula returns the #NUM! error in cell F3 as the criterion “North” (E2:E3) has a ‘duplicate’ in the field ‘Area’. It’s the string ‘North East’.

To understand the term ‘field’ please scroll up and take a look at the syntax of the DGET in Sheets.

The criterion “North” and “North East” are actually not duplicates.

Just modify the criterion in cell E3 to “North East”. The formula will then return 1800 as the output. So the issue is the exact match, not duplicates.

We can avoid this error if we know how to do an exact match in the DGET database function in Google Sheets.

To perform an exact match in DGET database function, include the = sign with the criterion.

See the examples below.

Criteria as Cell Reference in DGET

Let’s use the same above DGET formula here. To exact match, we just need to use the criterion in cell E3 in a different way.

See the screenshot. I hope that makes sense.

Exact Match - DGET Database Function in Google Sheets

Insert a single apostrophe and then an equal sign before the starting of the criterion. Without the apostrophe, Google Sheets will consider the entered criterion itself as some kind of formula.

Criteria (Hardcoded) within DGET

I like to use DGET in the above way. I mean the criterion from a cell reference. But if you want to use the exact match criterion within the DGET formula, use it as below.

=dget(A2:C8,3,{"Area";"=North"})

The equal sign makes the whole difference!

Exact Match in DSUM, DPRODUCT, DCOUNT, and DAVERAGE Database Functions in Google Sheets

Unlike DGET, you won’t find any formula errors related to exact match in database functions like DSUM, DPRODUCT, DCOUNT, DAVERAGE, etc. in Google Sheets. Because these functions aggregate values.

I am just using the function DSUM in my example for the exact match. It’s applicable to the other above database functions.

=DSUM(A2:C8,3,E2:E3)
DSUM Inexact Match Example in Sheets

The DSUM formula in cell F2 returns the total of the values 1000 in cell C3 and 1800 in cell C6. It’s the total of the ‘Qty’ in the ‘Area’ ‘North and ‘North East’.

To get the total only from the area ‘North’, as mentioned earlier, just change North in cell E3 to '=North.

When the DSUM criterion is within the formula, I mean hardcoded into the formula, the exact match will be as follows.

=DSUM(A2:C8,3,{"Area";"=North"})

Related Topics (Database Functions)

  1. The Ultimate Guide to Using Criteria in Database Functions in Google Sheets.
  2. How to Do a Case Sensitive DSUM in Google Sheets.
  3. How to Use Date Difference As Criteria in DSUM in Google Sheets.
  4. AND, OR in Multiple Criteria DSUM in Google Sheets (Within Formula).
  5. Google Sheets: How to Use Multiple Sum Columns in the DSUM Function.
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.

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

Sum Values by Month and Category in Excel

With the help of EOMONTH, UNIQUE, and SUMIFS functions in Excel, you can efficiently...

Sum Values by Categories in Excel

In Excel, the easiest way to sum values in a range by categories is...

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

4 COMMENTS

  1. Thanks, Prashanth.

    I was hoping to avoid using the = in front of the criteria as it looks a bit confusing to others, but seems like I’m stuck with that!

    I did find a tip to work around it though, which I’ll share in case anyone else looks at this thread. I changed the font color of the = to white to make it invisible. 🙂

    • Hi, Deborah Kragten,

      I would rather prefer the below method.

      The criterion in E2: North

      Formula:

      =dsum(A1:C5,3,{E1;"="&E2})

      Instead of;

      The criterion in E2: =North

      Formula:

      =dsum(A1:C5,3,E1:E2)

  2. This is really helpful thanks.

    In your DSUM example above;

    =DSUM(A2:C8,3,{"Area";"=North"})

    what if I want to use a cell reference instead of “=North” so that I can copy the formula down. In your example, Col E might have North, South, and West under Area with the formula then copied down from F2.

    I initially used just the cell ref in the normal way, then ran into the problem of it summing non-exact matches as you describe. my formula:

    =dsum('Transactions'!$A$3:$J$255,10,{"Ref";$B45})

    I’d like to hardcode the exact match functionality into the formula so I don’t have to put an apostrophe and equals in front of my data.

    Thanks!

    • Hi, Deborah,

      Good question 🙂

      The criterion must any way entered with = sign as shown on the image under the title ‘Criteria as Cell Reference in DGET’.

      Assume the criteria are in E3, E4, E5, and so on and the field label of the criteria is in E2.

      So when dragging the formula from F2, the field label E2 in the formula must be absolute, i.e. $E$2, and criterion E3 in the formula must be relative, i.e. $E3.

      Here is that DSUM exact match formula with drag-drop criterion reference.

      =DSUM($A$2:$C$8,3,{$E$2;$E3})

      When you drag this DSUM formula down, it picks the criterion from the rows down.

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.