Works: How to Calculate a Running Total/Average in a Database (124647)



The information in this article applies to:

  • Microsoft Works for Windows 95, version 4.0
  • Microsoft Works for Windows 95, version 4.0 4.5
  • Microsoft Works for Windows 95, version 4.0 4.5a
  • Microsoft Works 2.0a
  • Microsoft Works 3.0
  • Microsoft Works 3.0a
  • Microsoft Works 3.0b

This article was previously published under Q124647

SUMMARY

A running total or average displays the sum or average of all the values in a specific field up to any given record. In Microsoft Works, you can keep a running total and a running average by using self-referencing formulas. The table below resembles a database that contains running totals and averages, in which blank values are not counted in the average.

   Values  Number   Total  Average
   -------------------------------

     20      1        20     20
     40      2        60     30
             2        60     30
     60      3       120     40
     80      4       200     50
    100      5       300     60
				


To create a sample database similar to the one in this article, use the steps in the following procedure.

MORE INFORMATION

To create a table resembling the above example, do the following:

  1. In a new database, create 4 fields: Values, Number, Total, and Average.
  2. Switch to List view.
  3. In Record 1, type the following data (press ENTER after each entry):

    1. In the Values field, type 20.
    2. In the Number field, type 1.
    3. In the Total field, type the number located in Values.
    4. In the Average field, enter the following formula:

      =Total/Number

  4. In Record 2, enter the following data:

    1. In the Values field type, 40.
    2. In the Number field, enter the following formula:

      =Number+IF(Values,1,0)

    3. In the Total field, enter the following formula:

      =Total+Values

  5. Continue entering numbers above in the Values field.

    At this point, every value entered in the Values field will automatically place the correct values in the following 3 fields.
A running total will be calculated in the Total field while a running average will be calculated in the Average field.

Modification Type:MajorLast Reviewed:11/15/2004
Keywords:kbhowto KB124647