1
votes

I am creating a report (screenshot is attached below) in which I have to show running total of column Balance. This balance column value is generated by adding or subtracting dr and cr column value. For more explanation, if dr is 0 then cr value will be subtracted from balance value and if cr is 0 then dr value will be added to balance value, and the balance column first value will come from particulars (=opening) column's dr or cr value then the calculation will start and running total of balance will be made.

I have attempted some Crystal Report formulas to accomplish this but failed to get the required values. I have also attached snapshot of my attempted formulas.

First page of report this image is first page of report

This image is the formula I used in this report for running total. But this approach is not calculating the correct sum and this formula is not working on next page of report as it starts from the beginning on next page

this image is the formulas in this report

If anyone knows any other useful and easy way to calculate running total which is suitable in my current situation then please guide me.

2
Which header are you talking about - Siva

2 Answers

1
votes

You can accomplish it this way. Create two formula fields in report design, namely ff_Reset_Bal, ff_Cur_Bal and set their values in formula editor as under:

  1. ff_Reset_Bal

    whileprintingrecords;
    numbervar RunTotl;
    RunTotl:=0;
    
  2. ff_Cur_Bal

    whileprintingrecords;
    numbervar RunTotl;
    RunTotl:=RunTotl + {WLBills.dr} - {WLBills.cr};
    

Now place these formula fields in your report as under:

  1. ff_Reset_Bal in the Report Header Section (its Report Header NOT Page Header)
  2. ff_Cur_Bal in the Details Section (this is your Balance column in report)

Now hide ff_Reset_Bal by Right Click on it in Report Header, point to Format Field and then in the Common tab select Suppress

0
votes

You can create running total directly in CR - in Field Explorer add Running Total field. What to sum - for this I would create a formula, containing just {WLBills.dr} - {WLBills.cr}. If you have some grouping, remember to evaluate running total only at correct group change.