Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Running Total Fields Post Reply Post New Topic
Author Message
tfreeman
Newbie
Newbie
Avatar

Joined: 07 Jan 2008
Location: United States
Online Status: Offline
Posts: 4
Quote tfreeman Replybullet Topic: Running Total Fields
    Posted: 07 Jan 2008 at 11:10pm
I have developed a report that has multiple running totals that reset on group change.  I want to use the same running total fields in the report total section of the report.  When I change the fields to not change on group field change, the values increase for each group, which inflates each group.  I am trying not have to create additional running totals for same field calcualtion.
 
Thanks
tfreeman
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 08 Jan 2008 at 4:18am
Well, there are a few possible solutions.

First, go ahead, break down, and create new running totals.  You don't want to do that, so we skip that option.

Second, create a series of global variables.  In each group footer, increment the global variables with the value of the running totals.  Reference these global variables in your report footer.

Third, don't use running totals to calculate the values for the report footer.  Instead, use the Sum function.  Running totals are mostly only useful when you actually want to display your progress on each record.  If you just want to work with summary information, use summary fields.

The one caveat to that last option is that Sum doesn't have much flexibility.  You have to be summing a simple value.  If you want to sum some values but not others, or sum some kind of values that are weighted on the fly, you can't do that with just the Sum function itself.  Instead, you have to create a formula on each record, and sum that.  Note that the formula does not have to actually appear on the report.


IP IP Logged
tfreeman
Newbie
Newbie
Avatar

Joined: 07 Jan 2008
Location: United States
Online Status: Offline
Posts: 4
Quote tfreeman Replybullet Posted: 13 Jan 2008 at 11:40pm
Thank you for the information.  I have several additional questions that I am lost on.  I have developed several variables, and have quite a few more to create, that calculate the various record counts.  I have created a formula with the following code: (rptMainCalculations)
 
whilereadingrecords;
numbervar cMaleMembers;
numbervar cTotalMembers;
numbervar cFemaleMembers;
if{StakeData_.Sex} = "MALE" then
cMaleMembers := cMaleMembers + 1
else
cFemaleMembers := cFemaleMembers + 1;
cTotalMembers := cTotalMembers + 1;whilereadingrecords;
This formula is in the detail section of the report.  I have suppressed the detail and header sections of the report.  I only want the Group Footer and Report Footer to print.
 
I have put the following formula in the Group Footer section: (rptMembers)
 
whilereadingrecords;
numbervar cTotalMembers;
cTotalMembers;
 
(as an example)  this works for the first group, but the variables are not set to 0 on a group change.
 
I have placed the following formula in the Group Header section of the report: (rptGroupReset)
 
whileprintingrecords;
numbervar cMaleMembers;
numbervar cTotalMembers;
numbervar cFemaleMembers;
cMaleMembers := 0;
cFemaleMembers := 0;
cTotalMembers := 0;
I can't see what I am doing wrong.  Can you help me?
 
 
tfreeman
IP IP Logged
Savan
Senior Member
Senior Member
Avatar

Joined: 14 Dec 2007
Location: India
Online Status: Offline
Posts: 162
Quote Savan Replybullet Posted: 14 Jan 2008 at 12:20am
hi,
 
change "whileprintingrecords;" with "whilereadingrecords;" in the (rptGroupReset) formula and check.  or another way it create formula called "initval" and declare the variables in it and place the "initval" in the group header section and supress it.
 
initval (syntax would be as follows)
numbervar cMaleMembers := 0;
numbervar cTotalMembers := 0;
numbervar cFemaleMembers := 0;
 
 
Thanks
Savan
IP IP Logged
tfreeman
Newbie
Newbie
Avatar

Joined: 07 Jan 2008
Location: United States
Online Status: Offline
Posts: 4
Quote tfreeman Replybullet Posted: 14 Jan 2008 at 9:11pm
Thanks for your suggestions.  When I tried it all I got was rptMale = 0; rptFemale = 1 and rptmember = 0.  I don't know what else to try.
tfreeman
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 15 Jan 2008 at 4:45am
When you declared these variables, did you set the scope to Global?  I.e., your declarations should actually look like:


Global numbervar cMaleMembers;
Global numbervar cTotalMembers;
Global numbervar cFemaleMembers;


IP IP Logged
tfreeman
Newbie
Newbie
Avatar

Joined: 07 Jan 2008
Location: United States
Online Status: Offline
Posts: 4
Quote tfreeman Replybullet Posted: 17 Jan 2008 at 9:26pm
I have declared all of my variables as "global", set the variables to 0 in the group header; calculate the variables in the detail section; then display the variables in the group footer. 
 
The problem that I am having is the variables are not being reset to 0 when the group changes.  I have the formual that sets the variables to 0 in the group header and I can see that it get set to 0 the variables don't get reset the totals continue.
 
So, I am totally lost, I am not sure what else to try. 
 
If anyone can help I would appreciate it.
 
Thanks


Edited by tfreeman - 17 Jan 2008 at 9:27pm
tfreeman
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 18 Jan 2008 at 5:44am
I would try a few things at this stage.

First, go back and proofread everything with a fine tooth comb.  Make sure everything is set to Global.  Make sure everything is evaluating with "whilereadingrecords" on.  Make sure that your variable names are actually the same in every formula.

Then, I would try breaking things out into the smallest pieces possible, and testing them.  Create a separate formula for each of your variables, and show the current results on your report.  (Don't worry about how it looks, you'll delete or suppress them once you get them fixed.)  Watch them carefully to see how they behave.
IP IP Logged
RumeshChanchal
Newbie
Newbie


Joined: 15 Sep 2011
Location: India
Online Status: Offline
Posts: 2
Quote RumeshChanchal Replybullet Posted: 15 Sep 2011 at 4:44am
Hey Everyone,
Here I have simple article which specifies Running total fields nicely,
please check out the following links..........


http://mindstick.com/Articles/d482235f-3777-44d6-9599-5b790444e851/?Running%20Total%20Field%20in%20Crystal%20Report

Thanks !!!!
rumeshchanchal
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 15 Sep 2011 at 12:13pm
maybe I'm thinking too simple, but
have you tried creating a summery from the field you created running totals
(place field into the detail section then right click on the field select insert summery..... )

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.