To create a conditional running total
- To get started, create a report using the sample database, Xtreme.mdb. Link the Customer table and then place the following fields from left to right in the Details section:
{customer.CUSTOMER NAME} {customer.COUNTRY} {customer.LAST YEAR'S SALES} - On the Report menu, click Record Sort Expert.
- Sort the records based on the Customer.Customer Name field.
- On the View menu, click Field Explorer.
The Field Explorer dialog box appears.
-
Select Running Total Fields and click New.
The Create Running Total Field dialog box appears.
- Enter the name "USTotal" in the Running Total Name box.
- Highlight Customer.Last Year's Sales in the Available Tables and Fields box, and use the first arrow button to move it over to the Field to summarize box.
- Select sum from the Type of summary list.
-
In the Evaluate section of the dialog box, click Use a formula and then click the Formula button.
The Formula Workshop appears with Running Total Condition Formula active.
- Enter the following formula in the Formula box:
{Customer.Country} = "USA"This tells the program to evaluate the running total each time it comes to a record where Customer.Country is equal to "USA." The running total will ignore all other records (such as records for Canada).
- When the formula has the correct syntax, click Save and close.
You return to the Create Running Total Field dialog box.
- In the Reset section of the dialog box, click Never.
- Click OK to save the running total field.
The program returns you to the Field Explorer dialog box.
- Place the running total field in the Details section of your report.
- Now create the "CanadaTotal" running total field using the process outlined in steps 5-13. The only difference is that this time you will set the evaluation formula to:
{Customer.Country} = "Canada" - When you are finished, place the #CanadaTotal field in the Details section of your report