Crystal Reports for Rational Application Developer Designer Guide
To create a running total in a
one-to-many linking relationship
Create a report using the
Customer and Orders tables from the Xtreme sample database.
Select the
CUSTOMER_NAME, and
LAST_YEARS_SALES fields from the Customer table, and the
Order
ID and
Order
Amount fields from the Orders table, and place them in the Body
section.
In the
"Field
Explorer" view, select {CUSTOMER.CUSTOMER_NAME}, right-click on the
field and click
Group on
Field.
In the body of the report,
right-click the {CUSTOMER.LAST_YEARS_SALES} field and select
Summarize.
The summary is inserted in the Group
Footer.
If you look at the subtotals for
each group, you will notice they are inaccurate. This is because the
{CUSTOMER.LAST_YEARS_SALES} field is duplicated for each order in the report.
Follow the rest of this procedure to see how a running total produces an
accurate result.
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 "LYSrunning".
From the
Summarized
Field list, select {CUSTOMER.LAST_YEARS_SALES}.
From the
Summary
Operation list, select
Sum.
From the
Evaluate
Condition Type list, click
On change of
field.
From the
Evaluate
Condition list, select
CUSTOMER.CUSTOMER_NAME.
From the
Reset
Condition Type
list, click
On Change of
Group.
From the
Reset
Condition list, select
Group #1:
CUSTOMER_NAME.
Place the running total in
the
Group
Footer section.
Compare the running total amount with
the subtotal amount for each group. You will see the running total is accurate
while the subtotal is not.