AND, OR in Multiple Criteria DSUM in Google Sheets (Within Formula)

Published on

The use of multiple criteria in DSUM is easy if the criteria are in the form of cell references. That is the charm of database functions. But we can also use multiple criteria DSUM in Google Sheets with conditions included within the formula. You can master that ‘art’ in this new Google Sheets tutorial.

Learn all about the multiple criteria DSUM in Google Sheets including the AND, OR in the criterion. I am talking not about the logical AND, OR operators but the equivalents. You can understand that in the formula section below.

I have included enough examples to make you master the multiple criteria DSUM in Google Sheets. Here we go!

DSUM Database Function in Google Sheets

Syntax:

DSUM(database, field, criteria)

Here are some DSUM advanced formula examples with single and multiple criteria use.

First I am going to share with you the Dsum criteria use as the cell reference. Then you will get the equivalent criteria tips to use within the formula. Let’s use the sample data in the table below.

ABCDE
1nametermmathsphysicschemistry
2Student 1First908690
3Student 1Second948089
4Student 1Third967991
5Student 2First988975
6Student 2Second978278
7Student 2Third988489

DSUM with Single Criterion in Google Doc Sheets

Criterion as Cell Reference:

=DSUM(A1:E7,3,G1:H2)
DSUM Single Criterion

As per the syntax I have marked the database and criteria on the screenshot. Regarding the field, it’s the column number to sum. I have used 3 as the field number which is the ‘maths’ column.

In this example, there is only one criterion. Below is the equivalent DSUM formula where the criterion is within.

Criterion within Formula:

=dsum(A1:E7,3,transpose({"name","Student 1"}))

Actually, the Transpose is not a must here. But I have used it because in multiple criteria DSUM you will find it useful.

=transpose({"name","Student 1"})

To see what it does, enter the above formula in a blank cell. It will return the criteria as below.

name
Student 1

As a side note, the same you can achieve without using the Transpose function as below.

={"name";"Student 1"}

You can use either of the formulas to generate an array to use as the criterion.

If you are not familiar with creating arrays, please read this – How to Use Curly Brackets to Create Arrays in Google Sheets.

DSUM with Multiple Criteria in Google Sheets

The use of AND, OR logical operator equivalents comes in the multiple criteria DSUM formulas.

In the real sense, there is no such operator use in DSUM as it’s a database function. But we can achieve the same by using the criterion correctly.

OR Condition in Multiple Criteria DSUM in Google Sheets

Normally when we are using multiple conditions in the same column, without knowing, we are using the OR condition (this or that) in DSUM. See the examples.

Criteria as Cell Reference:

=dsum(A1:E7,3,G1:H4)
OR Condition in Multiple Criteria DSUM

This formula sums column C if values in column A are “Student 1”, “Student 2” or “Student 3”.

You can rewrite the above formula as below. In that, the criterion is a virtual array.

Criteria within the Formula:

=dsum(A1:E7,3,transpose({"name","Student 1","Student 2","Student 3"}))

AND Condition in Multiple Criteria DSUM in Google Sheets

If all the provided conditions are met, then the formula would return the correct output else 0.

Criteria as Cell Reference:

The formula sums column C if the column A value is “Student 1” and the column B values is “Second”.

AND Condition in Multiple Criteria DSUM in Google Sheets

Formula:

=dsum(A1:E7,3,G1:H2)

Criteria within Formula:

See how I am recreating the above multiple criteria within the DSUM formula.

=dsum(A1:E7,3,transpose({"name","Student 1";"term","Second"}))

I know by now you may have already mastered one technique, i.e. the use of AND, OR in DSUM in Google Sheets.

To polish what you have learned here is one more formula. In that, I am using AND, OR together in DSUM.

AND, OR Condition in Multiple Criteria DSUM in Google Doc Sheets

Here you may face one issue with the virtual criterion (criterion within formula).

AND, OR together in DSUM
=dsum(A1:E7,3,G1:H3)

This formula sums column 3 if the “name” of the student is either “Student 1” or “Student 2”. Also for the “Student 1“, the “term” must be “First” in column 2. For Student 2, the term is not applicable.

You can use the following formula to recreate the criteria.

transpose({"name","Student 1","Student 2";"term","First",""})

This replaces the criteria in G1:H3. Since there is no value in cell H3, I have used double quotes (equal to blank) at the end of the formula. Because in the virtual range the number of rows must match in both the columns.

=dsum(A1:E7,3,transpose({"name","Student 1","Student 2";"term","First",""}))

Conclusion

I have included lots of tips and tricks in this spreadsheet tutorial to make you master the Google Sheets DSUM function. But you may have seen I have missed one tip, i.e. how to sum multiple fields in DSUM.

In all the above formulas I have only used field # 3, i.e. the “maths” column to sum. In the next post, I’ll try to share with you how to use multiple fields in DSUM.

Update: See the 6th link under ‘Resources’ below.

Resources:

  1. How to Do a Case Sensitive DSUM in Google Sheets.
  2. How to Properly Use Criteria in DSUM in Google Sheets [Chart].
  3. Compare Sumifs, Sumproduct, Dsum with Example in Google Sheets.
  4. Difference Between SUMIFS and DSUM in Google Sheets.
  5. How to Use Date Difference As Criteria in DSUM in Google Sheets.
  6. Google Sheets: How to Use Multiple Sum Columns in the DSUM Function.
  7. Exact Match in Database Functions in Google Sheets – How-To.
  8. The Ultimate Guide to Using Criteria in Database Functions in Google Sheets.
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 Data but Keep Blank Rows in Excel and Google Sheets

Using a dynamic array formula or the FILTER command, we can sort data and...

Lookup Values Under Categories in Excel and Google Sheets

We can use a combination of XLOOKUP and VLOOKUP in both Excel and Google...

Extract Items Under a Category from the Same Column in Excel

In Excel, you can use a combination of the XLOOKUP and DROP functions to...

How to Create a Searchable Table in Excel Using the FILTER Function

Finding specific records, or rows containing the required information, is straightforward in Excel using...

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

2 COMMENTS

  1. =DSUM(A1:I31,"Item_Value",{"Who","him";"Asset_Debt","Asset"})

    The above formula does NOT sum up ‘Item_Value’ for all records having ‘him’ in the ‘Who’ field #AND# having ‘Asset’ in the ‘Asset_Debt’ field.

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.