Database Functions

Question:   I have a list of product sales with different transaction dates. How do I calculate the total sales for transactions between 2009/03/20 and 2009/03/30 by using one formula?  

Answer:  By using the DSUM function (Adds the numbers in a field (column) of records in a list or database that match conditions that you specify)

Why:  To calculate the total sales for products, for given a criteria range 

Applies To:  MS Excel 2003, 2007 & 2010

 

1.         Using the Excel worksheet below

 

 

 

 

 

2.         You must use copy and paste to enter the data labels in H4 & I4

3.          Use the DSUM function DSUM(database, field, criteria)

4.         Select cell I8 and enter: =DSUM(B4:F23,5,H4:I5)

5.         The answer will be $2,271.50

 

By using one formula the total sales for transactions between 2009/03/20 & 2009/03/30 have been easily calculated. This demonstrates the power of database functions like DSUM.

 

More on the Database function

The DSUM function syntax has the following arguments: 

  • Database Required.  The range of cells that makes up the list or database. A database is a list of related data in which rows of related information are records, and columns of data are fields. The first row of the list contains labels for each column.
  • Field Required.  Indicates which column is used in the function. Enter the column label enclosed between double quotation marks, such as “Age” or “Yield,” or a number (without quotation marks) that represents the position of the column within the list: 1 for the first column, 2 for the second column, and so on.
  • Criteria Required.  Is the range of cells that contains the conditions that you specify? You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column.