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:
- In Crystal Reports, open a report on which you will like to add.
- In the Field Explorer pane, right click on "Formula Fields", and select "New"
- Enter a name for the formula, then click "OK"
- The first formula is to declare a variable and set it to zero. The code will be like:
WhilePrintingRecords;
NumberVar myRunningTotal := 0 - 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.
- 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.
- 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.
- Create a third formula to display the values. The code will be like:
WhilePrintingRecords;
NumberVar myRunningTotal;
- 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