SAP Knowledge Base Article - Public

1203612 - First record is ignored in running total when using a shared date variable in the formula of a running total

Symptom

In Crystal Reports XI, when a running total on a field is created and a formula is written based on a shared date variable, the first record is ignored in the running total.

The following workflow is performed:

  1. Create a running total in the report based on a numeric field.
  2. Create a formula in the Use a formula option in the running total.
  3. Use a shared date variable in the formula.

When the report is refreshed then the first record is ignored in the running total.

Cause

This behavior occurs because shared variables use the same memory block to store the value of a variable throughout the main report and all of its subreports. Shared variables are even more general than global variables.

To use shared variables, the variable must be declared and assigned a value before it can be passed between the main report and the subreport.

In this example, there is no need to use a shared variable as there are no subreports.

Global variables use the same memory block to store a value throughout the main report. This value is then available to all formulas that declare the variable, except for those in subreports. The solution is to use a global variable.

Resolution

To resolve the behavior, create a formula and declare a global variable in it similar to the following:

Global dateVar dReportFor := DateValue(2007,12,4);
dReportFor;

Use this formula in the running total instead of using a formula containing a shared date variable.

Keywords

First record is ignored in running total while using a shared date variable in the formula of running total , 6924959 , KBA , BI-RA-CR , Crystal Reports designer or BusinessViews Manager , Bug Filed

Product

SAP Crystal Reports XI ; SAP Crystal Reports XI R2