• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1203
  • Last Modified:

Crystal Reports X - multplying each data item by previous value

Crystal Reports version X.  Looking to multiply each data item by previous as in a regular sum in a running total.

When adding  works as expected:

@DetailsFormula
whileprintingrecords;
global numberVar mult:=mult+{@ReturnFactor}

When multiplying - returns zero:

@DetailsFormula
whileprintingrecords;
global numberVar mult:=mult*{@ReturnFactor}


I have tried the following per a previous posting with the same results.

@DeclareFormulaHeader
whileprintingrecords;
global numberVar mult:=0;

@DetailsFormula
whileprintingrecords;
global numberVar mult:=mult*{@YourFormulaField}

@FooterFormula
whileprintingrecords;
global numberVar mult;

Any thoughts would be appreciated
0
rk2517
Asked:
rk2517
1 Solution
 
peter57rCommented:
I don't know what @returns factor does so this might not be on the mark.

But when you need to use the value from the previous record you need to test for the current record  being the first record and not do the calc for that record:


whileprintingrecords;
global numberVar mult;
if not Onfirstrecord then
mult:= mult* somevalue
else
mult:=somevalue;
0
 
RajendraDewaniCommented:
you can use previous

create a formula  eg, name myrunning total

formula contains


previous (<<Your Field Name>) *{@YourFormulaField}

Please check   previous (<<Your Field Name>)  as null in case of first record
0
 
mlmccCommented:
To test for NULL on a previous record use PreviousIsNull not IsNull(Previous({ }))

mlmcc
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now