Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Running Total/avg Post Reply Post New Topic
Author Message
martbar
Newbie
Newbie


Joined: 04 Apr 2012
Location: United States
Online Status: Offline
Posts: 15
Quote martbar Replybullet Topic: Running Total/avg
    Posted: 15 Oct 2012 at 12:24pm
I've set up a running total but I've run into an issue where its duplicating one of the values.
 
//@LT Sum
Shared NumberVar LT;
LT:=LT+{@Leads}
 
Shared NumberVar LT;
LT:=0
 
Shared NumberVar LT;
{@LT Sum}/distinctcount({Matches.Orders}, {@Origin})
 
So I've placed @LT Sum in the GH for Matches.Orders as this is where the sum needs to occur. I've placed @reset at the GH for @Origin as this is where the reset to 0 needs to occur. This appears to be working but for one flaw...its duplicating one of the values.
 
for example if 4 values being summed in @LT Sum was
1
4
5
6
 
the @avg formula is spitting out 22/4 = 5.5
its adding the 6 twice. It should be 16/4 = 4.
I've verified that its doing this on every output.
 
Let me know if you can help


Edited by martbar - 15 Oct 2012 at 12:31pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 15 Oct 2012 at 1:52pm
hmm...
just for debugging, have you set the summing formula to display on the report so that you can see that it is doubling up?
 
If so, have you tried moving the summing formula to another section?
 
You could also keep track of the number of items summed, so that you don't have to call the distinctcount...since it will count 1,1,2,2,3,3 as only 3 items and not 6...unless that is what you want, but that will throw off the simple average that you are using.
 
HTH
IP IP Logged
martbar
Newbie
Newbie


Joined: 04 Apr 2012
Location: United States
Online Status: Offline
Posts: 15
Quote martbar Replybullet Posted: 16 Oct 2012 at 1:36am
Yes, I displayed it and the sum formula is not doubling in the proper GH. It shows its working as it should. Its only in the GF where the avg formula shows a doubling of the largest value so in essence the average is doing (A+B+C+2*D)/4. I know I have the pieces in the right place but wasn't sure if I had to set a condition somewhere to avoid this doubling of one value.
 
I know what you mean about the distinctcount but its needed in this report.
IP IP Logged
martbar
Newbie
Newbie


Joined: 04 Apr 2012
Location: United States
Online Status: Offline
Posts: 15
Quote martbar Replybullet Posted: 16 Oct 2012 at 1:58am
changed the avg formula to
 
Shared NumberVar LT/distinctcount({Matches.Orders}, {@Origin})
 
and it works now
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.020 seconds.