Using Exact Match Criteria in Google Sheets Database Functions

An exact match in Google Sheets database functions means fully matching the criterion, not partially, in the criteria field.

It’s a simple but important concept, as it directly impacts the output of database functions.

You might wonder why this is so important. Let me explain.

Take the DGET function, for example. Multiple occurrences of similar conditions can prevent it from working properly. If your criterion is “North,” and the criteria column contains both “North” and “North East,” DGET will return an error due to the partial match of “North” within “North East.” Because “North East” starts with “North”.

Issues with Partial Matches in DGET Function in Google Sheets

In other database functions, using the same criteria will result in incorrect results, although they won’t return an error.

Issues with Partial Matches in DSUM Function in Google Sheets

However, you won’t face this issue when using numeric or date values as criteria.

Let’s explore how to apply exact match criteria in Google Sheets’ database functions (applicable to all functions listed in the Resources at the bottom).

Using Exact Match Criteria from Cell References in Database Functions

To ensure an exact match in database functions, place an equal sign before the criterion.

For example, to match North, you should specify it as =North. However, entering this directly in a cell will return a #NAME? error, as Google Sheets will interpret “North” as a named range that doesn’t exist.

To avoid this, precede the equal sign with an apostrophe. Enter the criterion as '=North.

Using Exact Match Criteria in Database Functions in Google Sheets

Example:

Assume your database is in the range A2:C8, where A2:C2 contains “Salesperson,” “Area,” and “Qty.”

Enter the criteria in E2:E3, with E2 containing Area and E3 containing '=North.

In cell F2, use the following formula to search the criteria in the database and return the corresponding value from the third column:

=DGET(A2:C8, 3, E2:E3)

Syntax: DGET(database, field, criteria)

How to Hardcode Exact Match Criteria in DB Functions

When hardcoding the criteria, you shouldn’t include the apostrophe for an exact match. You can rewrite the formula as follows:

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

For more information on using criteria, check out Mastering Criteria in Database Functions in Google Sheets.

Resources

New to database functions? The following tutorials cover all of them:

  1. DAVERAGE
  2. DCOUNT & DCOUNTA
  3. DGET
  4. DMAX
  5. DMIN
  6. DPRODUCT
  7. DSTDEV
  8. DSTDEVP
  9. DSUM
  10. DVAR
  11. DVARP
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.

Hierarchical Numbering Sequences in Excel

Creating hierarchical numbering sequences in an Excel spreadsheet can significantly improve the way you...

How to Easily Repeat a Sequence of Numbers in Excel

Excel offers multiple ways to accomplish tasks, and the simplicity of each approach depends...

Create a Sequence of Dates at Every Nth Row in Excel (Dynamic Array)

Would you like to create a sequence of dates in every nth row in...

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

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.