How to Use DSUM Function with Multiple Criteria in Excel

Get FREE Advanced Excel Exercises with Solutions!

An individual might need to sum up only the values that satisfy certain criteria from a large dataset. The DSUM function can be very useful if we want to add values based on multiple conditions or criteria in Excel. In this article, we will show you two examples of how to use the DSUM function with multiple criteria in Excel.


How to Use DSUM Function with Multiple Criteria in Excel: 2 Suitable Examples

In this article, we will demonstrate two suitable examples of how to use the DSUM function with multiple criteria in Excel. Here’s an overview of the dataset for our today’s task.

excel dsum multiple criteria


Example 1: Calculating Total Price Using DSUM Function with Multiple Criteria

In this example, we will calculate the total price of a product using the DSUM function with multiple criteria in Excel. We will walk you through the steps to do so.

Steps:

  • First of all, create a table with all the imposed criteria you want.
  • In this example, we want to calculate the Total Price for the following four criteria:
  1. Employee: Zack
  2. Date: > 31-05-2022
  3. Product: Earbuds
  4. Quantity Sold >= 50

  • Then select cell F21 and write down the following formula.
=DSUM(B4:F16,"Total Price",B20:E21)
  • After that, press  Enter , and you will have the total price for all imposed criteria.

excel dsum multiple criteria

  • Only rows 8 and 16 satisfy the four specified criteria in this example. If we sum up the total price of these two rows, we will get the exact result we got with the DSUM function.

Calculating Total Price Using DSUM Function with Multiple Criteria in Excel


Example 2: Calculate Total Price of Specified Entries Using VBA

In this example, we will run a VBA code to calculate the total price of specified entries. Read the following steps to learn how to do it.

Steps:

  • First, press  Alt + F11  to open the Microsoft Visual Basic window.
  • Next, from the Insert tab, go to,

Insert → Module

  • Then copy the following code and paste it to the Module window.
Sub DSUM_VBA()
Range("F21").Value = Application.WorksheetFunction.DSum(Range("B4:F16"), "Total Price", Range("B20:E21"))
End Sub

Use DSUM Function with Multiple Criteria in Excel to Calculate Total Price of Specified Entries Using VBA

  • After that, press  F5  to run the code and go back to your worksheet.
  • As a result, you will have the total price for the specified multiple criteria.

Use DSUM Function with Multiple Criteria in Excel to Calculate Total Price of Specified Entries Using VBA

Notes
  • Don’t forget to give proper cell references, or you won’t get the desired result.
  • Make sure that the specified criteria range does not overlap the table.

Download Practice Workbook

Download this practice workbook to exercise while you are reading this article.


Conclusion

Thanks for making it this far. I hope you find this article useful. Now you know two suitable examples of using the DSUM function with multiple criteria. Please let us know if you have any further queries, and feel free to give us any recommendations in the comment section below.


Related Articles


<< Go Back to Excel DSUM Function | Excel Functions | Learn Excel

What is ExcelDemy?

ExcelDemy - Learn Excel & Get Excel Solutions Center provides online Excel training , Excel consultancy services , free Excel tutorials, free support , and free Excel Templates for Excel professionals and businesses. Feel free to contact us with your Excel problems.
Alif Bin Hussain
Alif Bin Hussain

Alif Bin Hussain earned a BSc in Civil Engineering from Bangladesh University of Engineering and Technology. As an engineering graduate, he has a deep passion for research and innovation. He loves to play with Excel. In his role as an Excel & VBA Content Developer at ExcelDemy, he not only solves tricky problems but also shows enthusiasm and expertise in handling tough situations with finesse, emphasizing his dedication to delivering top-notch content. He is interested in C, C++,... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo