How do I add a running total or summary field on a formula field in crystal reports?
// Sample Report
Serial No. Premium Commission Net (Premium-Commission)
-----------------------------------------------------------------------------
1. 10 4 6
2. 40 30 10
---------------------------------------------------------------------------
Grand Total 50 34 16
In sample report, Net (Premium-Commission) is a formula field which gets evaluated for each row? How do I add a grand total/summary field for my formula? It seems we can add a summary field to only Command fields.
Suppose Net (Premium-Commission)
formula field name is {@Net}
. Now you have to create another three formula fields.
{@Net}
.Code will be writen in formula fields as below.
{@Initializer}
WhilePrintingRecords;
Numbervar dSum :=0;
{@Increment}
WhilePrintingRecords;
Numbervar dSum; //Don't initialize zero
dSum:=dSum+{@Net}; //{@Net} formula field must be return numeric value
{@Total}
WhilePrintingRecords;
Numbervar dSum; //Don't initialize zero
dSum;
Place all formula fields in their appropriate section and suppress {@Initializer}
and {@Increment}
formula field.