Excel: Summing a Field in a Database Based on CriteriaLast reviewed: October 13, 1995Article ID: Q24766 |
The information in this article applies to:
SUMMARYTo sum all the entries in a database field based on whether the record containing the field matches certain criteria, use the DSUM() function as follows
=DSUM(Database,"fieldname",Criteria)where "fieldname" is the name of the field containing entries to be summed (this name must be enclosed in quotation marks). As an alternative to indicating a field name in the second argument, you can type the index number of the field to be summed that corresponds to the order of the field names in the database. For example, if cell A1 contains the field name "Name," and cell B1 contains the field name "Number," the index of "Name" would be 1 and the index of "Number" would be 2.
MORE INFORMATIONIf the field "Cost" is the second field in the database, the DSUM() function can be entered as follows:
=DSUM(Database,"Cost",Criteria) -or- =DSUM(Database,2,Criteria)Database is the range of cells that make up the database (note that this range can be referred to with a defined name). Criteria is the range of cells that contain the database search criteria (note that this range can be referred to with a defined name). For additional information about using a database in Microsoft Excel, please see the following article(s) in the Microsoft Knowledge Base:
ARTICLE-ID: Q98910 TITLE : AppNote XE0186: Database Tips |
KBCategory: kbother
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |