Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 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.

Exact Matches with DSUM

Written by Allen Wyatt (last updated April 28, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


3

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:

="=ABC01"

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:

="ABC01"
=ABC01

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 Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Exact Matches with DSUM.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Saving Information in a Non-Document Text File

Need to store some information in a plain text file? It's easy to do when you use a macro.

Discover More

Changing the Program that Opens a File

If you have multiple versions of the same program on your system, Windows can become confused as to which version it ...

Discover More

Counting Ports of Call with a PivotTable

A PivotTable is a great way to aggregate and analyze data. Sometimes, though, it can be difficult to figure out how to ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Using the TRUNC Worksheet Function

Want to chop off everything after a certain point in a number? The TRUNC function can help with this need.

Discover More

Counting the Number of Blank Cells

If you need to count the number of blank cells in a range, the function to use is COUNTBLANK. This tip discusses the ...

Discover More

Getting the Name of the Parent Workbook

If you need to insert into a cell the name of the workbook in which a worksheet is contained, you can use the CELL ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

2019-10-13 08:02:58

Mike Malec

I figured out a way to use the Evaluate function in a named range to get it to do what I need. Thanks.


2019-10-12 22:02:33

Peter Atherton

Mike
Open the two books and where you want the codes just type = then point to the first code and, assuming the code is in a column, copy down till all the codes are entered. The Select all the formulas and use Paste Special, Values. If there are duplicate codes you can filter them out.

The other way is to use a Collection function but that's a macro. Post back if you want to go that way.


2019-10-11 15:08:19

Mike Malec

I have a spreadsheet of offices with mostly unique codes, but some some contain similar codes like your part number example above. I'm pulling the office codes from another spreadsheet and then using them as criteria for a DCOUNT formula on a spredsheet of sales. Is there anyway to get the office code from another spreadsheet, add the necessary ="=xxxx" format and then get that cell to be read as a formula. I can create the proper format with CONCATENATE, but then the result isn't being read as a formula. I'd prefer to do this without VBA, but can probably figure that out if it is the only option. Thanks for any help you can provide.


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.