Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Exact Matches with DSUM.
by Allen Wyatt
(last updated August 17, 2019)
Dave has a list of sales figures for some items that have similar part numbers. He uses DSUM to analyze the number of units shipped, based on the part number. For example, he may have part numbers such as ABC01, ABC01A, ABC01M, IFA01 and IFM01. When Dave uses DSUM to match a part number such as ABC01A, it works great. However, if he wants to do an analysis of part number ABC01, DSUM includes in its sum not only ABC01, but also ABC01A and ABC01M. Dave wonders how he can get DSUM to return the correct totals for exact matches only on the part number.
When using DSUM, you need to be very careful with how you enter your criteria. For instance, let's say you enter ABC01 in the criteria table. Do this, and you'll get what you've noticed: DSUM matches all part numbers that begin with those five characters.
The solution is to enter your criteria in this manner:
Note the two equal signs in what you enter. The first one tells Excel to accept, as a literal, what follows in the quote marks. (It is, essentially, a formula you are entering.) When entered this way, the DSUM function matches only those part numbers that are exactly ABC01.
Interestingly, neither of the following works as a criterion:
Of course, if all you want to do is figure out how many units of a particular part number were shipped, you might consider using either the SUMIF or SUMIFS functions instead of DSUM. It only makes sense to use DSUM when you have multiple criteria you want to check in your analysis. The SUMIF and SUMIFS functions don't have the same strict requirements on entering criteria.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10591) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Exact Matches with DSUM.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
The COMBIN function is used to determine the number of combinations that can be made from a group of elements. This tip ...Discover More
The MODE function is used to determine the most frequently recurring value in a range. This tip explains how to use the ...Discover More
Ever want the IF function to only return a value if the condition it is testing is true, and not if the condition is ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.