Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: How to calculate the Max Value of a Running Total Post Reply Post New Topic
Author Message
bspencer1
Newbie
Newbie


Joined: 26 Nov 2013
Online Status: Offline
Posts: 26
Quote bspencer1 Replybullet Topic: How to calculate the Max Value of a Running Total
    Posted: 08 Jan 2014 at 4:24am
Hello, everyone.
 
I am sure this question has been asked before, but I could not find a similar posting on this site.  I have a running total (called Running Balance) in my report.  I am calculating the running account balance for customers and am re-setting on the change of customer (GH2). 
 
I would like to figure out the maximum value of that running total and place that value in either the GH2 or GF2.  I have included an image below.  Not sure how long the image will be available as I posted it on a free forum pic uploading site called postimage.org (they say they will not delete it).  In the image, I have attempted to illustrate what I am trying to accomplish with the red text.  How can I do this?
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 08 Jan 2014 at 5:03am
well, running totals are not my specialty...DBlank seems to get them, but here are 2 ways off the top of my head to get what you are after.

1) create a section below the running total (I am guessing that it is in Details...so a Details B) just to be sure that the running total has been incremented.
Create a formula like:
shared numbervar maxBal;
if {@runningTotal} > maxBal then
maxBal := @runningTotal;

I would probably try suppressing the new section, the formula should still work, then in the GF2 you would put a formula like:
shared numbervar maxBal;

and just to complete the trilogy, in the GH2 you would have a formula like:
shared numbervar maxBal:=0;
""//will hide the 0 on the report.

the other way would be to basically use the same values as above, but calculate the running total yourself...
so the only 'big' difference would be that you don't need the running total or the extra section. The formulas would look like:
gh2: shared numbervar maxBal:=0;
shared numbervar rt:=0;
""

detail:
shared numbervar maxBal;
shared numbervar rt;
rt := rt + {table.field};
if rt< maxBal then maxBal:= rt;
""

gf2:
shared numbervar rt;
and another formula
shared numbervar maxBal;

some ideas, hopefully one of the works for you.
IP IP Logged
bspencer1
Newbie
Newbie


Joined: 26 Nov 2013
Online Status: Offline
Posts: 26
Quote bspencer1 Replybullet Posted: 08 Jan 2014 at 10:34am
Lockwelle, I thank you. I used the first suggestion and it works fine in the group footer.  I will not pretend to understand exactly why it works, because I haven't worked long enough with Crystal to have to do too many things like this...but little by little, it should begin to sink in.

Edited by bspencer1 - 08 Jan 2014 at 10:44am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 08 Jan 2014 at 10:44am
Glad to hear it.

Brief explanation:
GH2: this resets the variable
DetailB: this checks after every line to see if the value of the running total is greater than the variable, if it is, store the new value in the variable
GF2: Display the value.

If CR didn't have running totals or don't quite understand them (like me) then you can use a similar method to build your own running totals (which is how I do running totals)

Hope this helps and lets you add one more tool to the kit
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.