SAP Knowledge Base Article - Public

1211588 - How to create a manual running total in Crystal Reports?

Symptom

  • How do you use variables in to create a manual running total?
  • How can you create a manual running total using formulas in Crystal Reports?

Environment

  • SAP Crystal Reports 2016
  • SAP Crystal Reports 2020

Resolution

  • A Manual Running Total consist of 3 formulas: Reset, Accumulate, Display. To create a manual running total using formulas in Crystal Reports:
      
    1. In Crystal Reports, open a report on which you will like to add.
        
    2. In the Field Explorer pane, right click on "Formula Fields", and select "New"
       
    3. Enter a name for the formula, then click "OK"   
        
    4. The first formula is to declare a variable and set it to zero. The code will be like:

           WhilePrintingRecords;
           NumberVar myRunningTotal := 0

    5. Insert the formula in a section where you want to intialise the variable, or reset the value.
      For example, insert the formula in a Group Header section to reset the value for each group.
         
    6. Create a second formula to accumulate the values. The code will be like:

           WhilePrintingRecords;
           NumberVar myRunningTotal;
           myRunningTotal := myRunningTotal + 1;

       Note: You can add conditions, use database fields to summarize,...
       The above is just a simple example counting the number of time the formula is evaluated.
         
    7. Insert the accumulate formula in a section where it will accumulate the values.
      For example: Insert the formula in the Details section of the report.
         
    8. Create a third formula to display the values. The code will be like:

           WhilePrintingRecords;
           NumberVar myRunningTotal;
         
    9. Insert the display formula in the section where you want to display the value.
      For example: Insert the formula in the Group Footer section to display the value.

Keywords

CR, RT, Running Totals , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

Product

SAP Crystal Reports 2016 ; SAP Crystal Reports 2020