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
A | B | C | D | E | |
1 | name | term | maths | physics | chemistry |
2 | Student 1 | First | 90 | 86 | 90 |
3 | Student 1 | Second | 94 | 80 | 89 |
4 | Student 1 | Third | 96 | 79 | 91 |
5 | Student 2 | First | 98 | 89 | 75 |
6 | Student 2 | Second | 97 | 82 | 78 |
7 | Student 2 | Third | 98 | 84 | 89 |
DSUM with Single Criterion in Google Doc Sheets
Criterion as Cell Reference:
=DSUM(A1:E7,3,G1:H2)
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)
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”.
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).
=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
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:
- How to Do a Case Sensitive DSUM in Google Sheets.
- How to Properly Use Criteria in DSUM in Google Sheets [Chart].
- Compare Sumifs, Sumproduct, Dsum with Example in Google Sheets.
- Difference Between SUMIFS and DSUM in Google Sheets.
- How to Use Date Difference As Criteria in DSUM in Google Sheets.
- Google Sheets: How to Use Multiple Sum Columns in the
DSUM Function. - Exact Match in Database Functions in Google Sheets – How-To.
- The Ultimate Guide to Using Criteria in Database Functions in Google Sheets.
=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.
Hi, Mike H,
Your criteria use is wrong.
As per my Sheet’s Locale, which is the UK, it must be as below.
transpose({"Who","him";"Asset_Debt","Asset"})
If you see error even after making the above change, then see this Locale setting guide – How to Change a Non-Regional Google Sheets Formula.
If you let me know your sheets’ ‘Locale’, then I may be able to tune the formula for you.