Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Calculating the total in balance sheet Post Reply Post New Topic
Author Message
maas
Newbie
Newbie


Joined: 26 May 2009
Location: Bahrain
Online Status: Offline
Posts: 15
Quote maas Replybullet 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

Example:

Group Header 1a: Account No. 400005
Group Header 1b: Opening Balance = 190912.08
( Details structure: {deal_no} {@drnum} {@crnum} {@balance})
Details:                  123               23.08           0                  190935.16
                             2411               0               23.02             190912.14

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.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 24 Mar 2015 at 10:21am
Do you have duplicate rows you are hiding and this is why you are using the Previous() functions?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet 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.

HTH
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
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



This page was generated in 0.031 seconds.