Crystal Reports for Rational Application Developer Designer Guide
To create a conditional running
total
Create a report using the
Customer table from the Xtreme sample database.
Select the
CUSTOMER_NAME,
Country, and
LAST_YEARS_SALES fields from the Customer table, and place
them in the Body section.
On the
Crystal
Reports menu, click
Record
Sorting.
In the
Record
Sorting dialog box, sort the records based on the
{CUSTOMER.CUSTOMER_NAME} field.
In the
"Field
Explorer" view, right-click
Running
Totals, and click
New.
Select the new running
total.
The running total settings are
displayed in the
"Properties" view.
In the
"Properties" view, in the
Name box, type the name "USTotal".
From the
Summarized
Field list, select {CUSTOMER.LAST_YEARS_SALES}.
From the
Summary
Operation list, select
Sum.
From the
Evaluate
Condition Type list, click
Use
Formula.
Double-click
Evaluate
Condition.
The running total formula is
displayed on the Formulas tab.
Under USTotal, type the
following formula:
{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).
From the
Reset
Condition Type list, select
Never.
Select the Layout tab, and
place the running total field in the Body section of your report.
Now create the
"CanadaTotal" running total field using the process outlined in steps 5-13, but
this time you will set the following evaluation formula:
{CUSTOMER.Country} = "Canada"
When you are finished,
place the
#CanadaTotal field in the Body section of your report.
Note: If you only want
to see a grand total of the Canadian and American sales, place the two running
total fields you created in the Report Footer section of your report.