Topic: Calculating the total in balance sheet Posted: 24 Mar 2015 at 10:07am
Hi,
I need your assistant and help as I am facing some difficulties while preparing the balance sheet report in Crystal.
My report Structure looks similar to this:
Group Header 1: {gl.COA_CODE}
Group Header 1A: Subreport to get Opening Balance and to get the total for every code
Group Header 1B:{@shared ZZ}
Details: {deal_no} {@drnum} {@crnum} {@balance}
The {@drnum} formula:
if {gl.Amount} > 0 then {gl.Amount} else 0
The {@crnum} :
if {gl.Amount} < 0 then {gl.Amount} else 0
The {@balance} formula should take the {@shared ZZ} (which is the Opening Balance) + {@drnum} + {@crnum} and then it should do the calculation for the others for the same.
Currently for the first printed record, the formula {@balance} is showing properly the amount which is {@shared ZZ} + {@drnum} + {@crnum}, but when it goes to the second deal, it gave me wrong results. Kindly refer to the below formula details which I am using in the {@balance}:
CurrencyVar Total;
if PreviousIsNull ({gl.COA_CODE}) then Total:= {@shared ZZ} else
if (Previous ({gl.COA_CODE})<> {gl.COA_CODE}) or (Previous ({gl.CCY}) <> {gl.CCY}) )
then
Total:=Total+{@drnum}+{@crnum} else Total:= {@shared ZZ} +{@drnum}+{@crnum}
So how can I fix the {@balance} to do the calculations properly for the other below deals.
Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Posted: 01 Apr 2015 at 7:10am
Previous is a dangerous function, as it does not care about grouping boundaries.
The other thing to try is to break the formula for balance into smaller pieces so that you can check that what CR is doing is what you think is should do.
for example:
you could print the previous value and the current value and if CR returns true or false (hopefully this is correct). You could also print out the drnum and the crnum and their sums and then compare to the total and see if things are checking out.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum