Get help

Help center

Guides and answers

Contact support

Write to our team

Sign in to

Workflows

Build processes with your team

Automations

Connect files and automate tasks

One system, four parts

AI agents

Virtual Employees that work 24/7

Automations

Connect files and automate tasks

Workflows

Build processes with your team

Data Space

Trusted data sharing and control

Solutions by department

Finance

Reports, budgets, and reconciliations

Inventory and manufacturing

Stock, orders, and production in one view

HR

Timesheets, attendance, and reviews

Project management

Status and workload across projects

Sales and CRM

Leads and deals kept up to date

Education

Student records and school data

Finance

Turn manual finance work into reports that update themselves.

What Finance teams automate

  • Track payables and receivables
  • Build cash flow statements
  • Compare budget against actuals

Inventory and manufacturing

See stock levels and automate ordering.

What inventory and manufacturing teams automate

  • Track inventory across multiple sites
  • Connect sales, purchasing, and warehouse data
  • Link a barcode scanner to your sheet

HR

Run recruitment, attendance, and OKR tracking from your sheets.

What HR teams automate

  • Track recruitment and onboarding
  • Record team OKRs and results
  • Track check-ins, check-outs, and leave

Project management

Assign tasks and track hours without manual updates.

What project teams automate

  • Assign tasks and track status changes
  • Estimate effort and log hours worked
  • Track milestones across projects

Sales and CRM

Track leads and sales performance with automated reports.

What sales teams automate

  • Track and convert leads
  • Set sales goals and track team metrics
  • Monitor sales KPIs on dashboards

Education

Automate attendance, grades, and school purchasing.

What schools automate

  • Track attendance and notify parents
  • Record and compare class grades
  • Track inventory lent to students and staff

Find a use case

By department

How each team uses Sheetgo

By industry

How each industry uses Sheetgo

By company size

Small, medium-sized, or large

Learn

Blog

Guides and product news

Customer stories

How teams like yours use Sheetgo

Help center

Guides and answers

Why Sheetgo

Compare

How Sheetgo compares with other tools

Security

How we protect your data

Trust center

Our compliance details

Sign in to

Workflows

Build processes with your team

Automations

Connect files and automate tasks

One system, four parts

AI agents

Virtual Employees that work 24/7

Automations

Connect files and automate tasks

Workflows

Build processes with your team

Data Space

Trusted data sharing and control

Solutions by department

Finance

Reports, budgets, and reconciliations

Inventory and manufacturing

Stock, orders, and production in one view

HR

Timesheets, attendance, and reviews

Project management

Status and workload across projects

Sales and CRM

Leads and deals kept up to date

Education

Student records and school data

Find a use case

By department

How each team uses Sheetgo

By industry

How each industry uses Sheetgo

By company size

Small, medium-sized, or large

Get started

Templates

Ready-made workflows to start from

Learn

Blog

Guides and product news

Customer stories

How teams like yours use Sheetgo

Help center

Guides and answers

Why Sheetgo

Compare

How Sheetgo compares with other tools

Security

How we protect your data

Trust center

Our compliance details

Help center

Guides and answers

Contact support

Write to our team

Workflows

Build processes with your team

Automations

Connect files and automate tasks

How to use DSUM in Google Sheets (criteria and examples)

Google Sheets features many categories of built-in functions, including twelve database functions. These functions can only be used with data structured like a database table. In other words, the first row contains the fields or column labels, and the subsequent rows are the individual records. All the database functions have the same syntax, but each performs a different operation. When you need to sum values in your database based on specific criteria, you can use the DSUM function in Google Sheets.

In this guide, you will learn about the syntax for the DSUM function and how to format the criteria. First, you have step-by-step instructions on how to use DSUM with a single criterion. Additionally, you have detailed examples of how to use DSUM with multiple criteria applied to a single field and how to use it with multiple criteria applied to different fields. Finally, you will learn the difference between DSUM and the SUMIF and SUMIFS functions and when it’s appropriate to use each one. You’ll also see how to write criteria as an array literal and why DSUM sometimes returns 0.

What is DSUM?

The DSUM function returns the sum of values selected based on criteria applied to a field in your table-like array. The D stands for database, so DSUM works much like a sum query on a database table. Like other database functions in Google Sheets – e.g., DGET, DPRODUCT, or DCOUNT – DSUM requires data formatted like a database table, where the first row contains the field names.

DSUM syntax

The DSUM function in Google Sheets has the following syntax:

=DSUM(database, field, criteria)
  • database: the array or range containing the data to consider. The data has to be structured as a table where the first row contains the column headers or field labels.
  • field: specifies the column containing the values you want to sum. You can use the text corresponding to the column header or an index number. When using an index, remember that the value of the first column is “1”.
  • criteria: an array or range with zero or more criteria to filter the values before summing them.

Criteria can be specified in two different ways:

  • A range of cells containing the criteria array.
  • An array expression describing the criteria array.

This guide will focus on the first method as it provides more flexibility: it’s easier to modify the criteria array. Additionally, the first method will save you a lot of typing and curly brackets. The array form is covered in the criteria section below.

How to use DSUM in Google Sheets

In the cell where you want the result, type the DSUM function and select your table as the database. Next, type the column label or field name as the field. Alternatively, you can use the column index. Finally, add the conditions that values must meet to be summed.

1. Set up criteria

The first step is to set up the criteria array. In this case, I will use a single criterion to sum the sales of FirstProduct. In an empty cell, type the field name (product) and type the criterion in the cell below it (FirstProduct).

DSUM Google Sheets — criteria range with the product header and FirstProduct below it, next to the transactions table

2. Type the DSUM function

In the cell where you want the result, type the DSUM function. Select the range of cells containing the database or type the range name as the first parameter.

DSUM Google Sheets — DSUM typed in K3 with transactions as the database and the syntax tooltip open

3. Add the field and criteria

For the second parameter, type the field label or column between quotation marks: “amount”. For the third parameter, select the range of cells containing your criterion.

DSUM Google Sheets — formula with the amount field and the criteria range J2:J3 selected

4. Get the DSUM result

Remember to close the parenthesis and press ‘Enter’ to see the result.

DSUM Google Sheets — result of $376,335.34 for FirstProduct sales in cell K3

How to write DSUM criteria in Google Sheets

The criteria array works like a small table. Its first row holds field names that match the headers of your database exactly, and the rows below hold the conditions. DSUM reads it with two rules:

  • Conditions in the same row must all be true (AND).
  • Conditions in different rows are alternatives (OR): a record counts if it matches any one row.

A condition can be a value, such as FirstProduct, or a comparison, such as >=1/1/22 or <2/1/22. To set a range on one field, repeat its name in two columns, as in the date example below.

DSUM with multiple criteria

Put each AND condition in its own column and each OR alternative in its own row. When you combine both, repeat the AND conditions on every row. A blank cell sets no condition, so a row that leaves one out matches every value in that field. The examples below walk through each case.

DSUM criteria as an array literal

Instead of a range, you can type the criteria into the formula as an array literal. Commas separate columns and semicolons separate rows: the first row holds the field names and each row after it holds conditions. With the sample data in this guide, this formula sums the sales of FirstProduct:

=DSUM(transactions,"amount",{"product";"FirstProduct"})

This one sums the sales of FirstProduct or SecondProduct made by Agent1:

=DSUM(transactions,"amount",{"product","sales_agent";"FirstProduct","Agent1";"SecondProduct","Agent1"})

If your spreadsheet locale uses a comma as the decimal separator, separate columns with a backslash instead of a comma. Array literals suit one or two fixed conditions. For longer criteria, a range is easier to read and change.

DSUM examples with multiple criteria

Now that you know how to use DSUM with a single criterion, it’s time to use it with multiple criteria. The first examples focus on multiple criteria applied to a single field. In the first case, I want to include rows that match any of the criteria (OR). In the second, I want to include rows with values in a specific range by specifying the maximum and minimum values (AND). The third example focuses on applying multiple criteria to different fields (AND).

Google Sheets DSUM with multiple criteria for the same column (OR)

Using DSUM, you can apply multiple criteria to the same column. Your criteria array can contain multiple rows under the field name, with each criterion on its own row. For this example, I want to sum the records if they contain “FirstProduct” or “SecondProduct”.

1. Set up the criteria array as shown below.

DSUM multiple criteria — OR criteria range with FirstProduct and SecondProduct under the product header

2. In an empty cell, type the DSUM function and select the table as the database.

DSUM multiple criteria — DSUM typed under a sum header with transactions as the database

3. Type the field between quotation marks, and after the comma, select the cells with the criteria array.

DSUM multiple criteria — formula with the amount field and the criteria range J1:J3 selected

4. Press ‘Enter’ to see the result.

DSUM multiple criteria — result of $755,096.26 for FirstProduct or SecondProduct sales

Google Sheets DSUM with multiple criteria for the same column (AND)

In this example, you’ll learn how to apply multiple criteria to a single column using AND. Follow the steps below to sum the sales made between two dates: on or between January 1st and January 31st.

1. Set up the criteria array as shown below.

DSUM multiple criteria — two date columns set to on or after 1/1/22 and before 2/1/22

2. In the cell where you want the result, type the DSUM function and select the table as the database.

DSUM multiple criteria — DSUM typed in L2 with transactions as the database

3. Type the field between quotation marks as the second parameter, and select the cells with the criteria array as the third.

DSUM multiple criteria — formula with the amount field and the date criteria range J1:K2 selected

4. Close the parenthesis and press ‘Enter’ to see the result.

DSUM multiple criteria — result of $96,343.95 for sales made in January 2022

Google Sheets DSUM with multiple criteria for different columns

In this example, you will learn to apply different criteria to different fields by structuring the array using AND and OR logic. For records to be included in the sum, they must match all the criteria specified for each field.

In this case, the record must contain “FirstProduct” OR “SecondProduct” in the “product” field and “Agent1” in the “sales_agent” field. Additionally, the date must be on or after January 1st but before July 1st.

1. Set up the criteria array as shown below. In this case, it will contain four columns and three rows, as shown below. Since there are two conditions in the first field (OR), the criteria for the other fields must be repeated in each row.

DSUM criteria — range J1:M3 with product, sales_agent and two date columns on two rows

2. In the cell where you want the result, type the DSUM function and select the table as the database.

DSUM criteria — DSUM typed in N2 with transactions as the database

3. Type the field name in quotes as the second parameter and select the criteria array as the third.

DSUM criteria — formula with the amount field and the criteria range J1:M3 selected

4. Press ‘Enter’ to see the result.

DSUM criteria — result of $104,289.00 for Agent1 sales of both products

Why DSUM returns 0

If DSUM returns 0 when you expect a total, check the field first. Like SUM, DSUM adds only numbers, so pointing it at a text column, such as product names, gives you 0.

Then check the criteria labels. Each one has to match a database header exactly. A criteria label that says Protein won’t match a header that says Protein (g), so no record matches and the sum is 0.

What is the difference between DSUM and SUMIF?

SUMIF and SUMIFS can be used on data that is not formally structured. To use the DSUM function, you must structure your data like a database table, with field names or column headers in the first row. This makes it easy to specify criteria without writing long or complex expressions.

Therefore, if the data you want to use is not structured in a database-like table, you can use SUMIF or SUMIFS. However, if your data is already structured as a database table, DSUM requires less explicit cell referencing, and criteria can also be supplied in tabular form. If you prefer the formula approach, see how to use SUMIFS with multiple criteria.

Conclusion

The DSUM function in Google Sheets is useful and flexible. While it does require that you structure your data in a specific way, this makes it easier to use with multiple conditions using both AND and OR logic. The SUMIF and SUMIFS functions can be used with unstructured data, but you need to write longer conditions with many explicit cell references and logical operators to join them. DSUM, on the other hand, allows you to specify your criteria array as a table, where the placement of the field names and values determines the logic. In other words, if your data is already structured like a table in a database, DSUM will get results with a cleaner formula and much less typing.

To learn about other methods of adding numbers in Google Sheets, check out our guide on how to add numbers in Google Sheets.

DSUM is one of several ways to filter and total data in Google Sheets. For more control over which rows you pull out, see the FILTER formula and the QUERY formula.

You may also like…

google sheets features and formulas

How to find nominal interest rate using Google Sheets

Sarah is a young professional making significant financial decisions. From credit cards to mortgages, student loans, and investment...
google sheets features and formulas

Pull Google Calendar data into Google Sheets using Apps Script

This post was originally published in our community forum. Objective : This guide demonstrates how to use Google Apps Script to pull data...
google sheets features and formulas

Using the PROPER function to capitalize the first letter of each word in Google Sheets

Note: This post was originally published in our community forum. Ever found yourself needing to clean up a list of names, titles, or any...