Crystal Reports  

Creating Conditional Running Totals

There may be times when you have a list of ungrouped values, and you only want to subtotal some of the values in the list.

Suppose that:

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.

To create a conditional running total

  1. In the Field Explorer, right-click Running Total Fields and click New.
  2. In the Create Running Total Field dialog box, enter a name for the running total object in the Running Total Name field.
  3. In the Available Tables and Fields area, select the first field you want to summarize.
  4. Click the first arrow button to add the field to the Field to summarize box.
  5. In the Type of summary list, click sum
  6. In the Evaluate section of the dialog box, click Use a formula and then click the Formula button (labelled x+2).
  7. In the Running Total Condition Formula dialog box, enter the formula in the formula box.

    For example, if using Crystal syntax to create a running total of U.S. sales, you would enter:

    {Customer.Country} = "USA"

    If using Basic syntax, you would enter:

    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.

  8. Click the Save and close button.
  9. In the Reset section of the Create Running Total Field dialog box, click Never.
  10. Click OK to save the running total field.
  11. Create another running total using the above steps. The only difference will be the value in the formula.
  12. Return to the Field Explorer and locate your Running Total Fields.
  13. Either drag both of your running total fields onto the Details section of the report, or, if you want to view a grand total, drag them onto the Report Footer section of your report.
    Note   A running total that is placed on a report is indicated by the # prefix (for instance, #Total1).

See Also

Placement of Running Total Fields | Creating Running Totals