Creating conditional running totals
There may be times when you have a list of values, and you only want to subtotal some of the values in the list. For example:
-
You have a list that contains both Canadian and U.S. customers.
-
You want to keep customer records sorted alphabetically based on customer name.
-
You do not want to break the data into groups based on the country.
-
You want a total of the values from just the Canadian records.
-
You also want a total of the values from just the U.S. records.
To accomplish this, create two running totals, one to keep a running total of the U.S. records, and one to keep a running total of the Canadian records.
-
USTotal
Maintains a running total of the U.S. records.
-
CanadaTotal
Maintains a running total of the Canadian records.