Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Incorrect running totals Post Reply Post New Topic
Author Message
adders
Groupie
Groupie


Joined: 09 Aug 2010
Online Status: Offline
Posts: 53
Quote adders Replybullet Topic: Incorrect running totals
    Posted: 31 Jul 2013 at 10:46pm
Hi,

I have an issue with crystal reports calculating the incorrect sum from running totals, for example I have the column used time:

0.55
0.20
0.34
0.20
0.47

I use a running total to add the column up, I also use a running total to count the rows. This gives me a figure of 0.37 which at first seems fine, however when I double check the calculation on a calculator I get 0.352??

I have a reset in place for every change of group! For every group that has bigger values, the spread from the sum gets bigger.

Any ideas would be great
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Aug 2013 at 3:37am

Just a guess but it may have to do with rounding.

although you are only dispalying 2 decimal points tha actual value may be 3 or more and the RT is usig the original data, not the rounded data you are using in the calculator version.
IP IP Logged
adders
Groupie
Groupie


Joined: 09 Aug 2010
Online Status: Offline
Posts: 53
Quote adders Replybullet Posted: 01 Aug 2013 at 6:12am
Unfortunately I have checked the rounding s and it adds up to the exact row amounts yet the total is incorrect   
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 01 Aug 2013 at 6:21am
are you using a Running Total or shared variable formula that you are calling a running total?

Edited by DBlank - 01 Aug 2013 at 6:22am
IP IP Logged
adders
Groupie
Groupie


Joined: 09 Aug 2010
Online Status: Offline
Posts: 53
Quote adders Replybullet Posted: 04 Aug 2013 at 10:04pm
Just a running total.

I have since seen that when displaying the final values in the group footer, it's adding the last row in twice so the row count is 6 not 5?

Why is it doing that?

Thanks

Edited by adders - 05 Aug 2013 at 1:29am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Aug 2013 at 3:42am
if you were using a shared variable I would say it is because you are not using a seperate display formula for the footer. If you just place the same formula you use to calculate in the detail and the GF it will do another calculation for the footer which re-uses the value from the last row in the group.
In your RT are you using an evaluation formula? If so what is it? If not how is your RT set up?


Edited by DBlank - 05 Aug 2013 at 3:43am
IP IP Logged
adders
Groupie
Groupie


Joined: 09 Aug 2010
Online Status: Offline
Posts: 53
Quote adders Replybullet Posted: 05 Aug 2013 at 4:20am
Both running totals are below:

WhilePrintingRecords
NumverVar UsedHours;
UsedHours := UsedHours + {UsedTime}

Used time is just total time / total goods (this currently works fine)

WhilePrintingRecords
NumverVar Records;
Records := Records + 1 (I then have my count records RT)

Both running totals are run in the details section.

I then use RT_UsedHours / RT_Records to get the time taken (In the group footer)

I have a reset in the group which also works fine.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Aug 2013 at 4:27am
so you are using variable formulas and not Crystal's built in Running Totals.
The same way you have reset formuals for the headers you need dispaly formula for the footer.
If you just place the same formula that you use for the rew leve evaluations then it will evaluate again on the footer and add more values to the result (repeats the last row of the group)
IP IP Logged
adders
Groupie
Groupie


Joined: 09 Aug 2010
Online Status: Offline
Posts: 53
Quote adders Replybullet Posted: 05 Aug 2013 at 10:07pm
Lovely thanks, all sorted.
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.016 seconds.