Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Running Total in report header? Post Reply Post New Topic
Page  of 2 Next >>
Author Message
JFinzel
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Location: United States
Online Status: Offline
Posts: 49
Quote JFinzel Replybullet Topic: Running Total in report header?
    Posted: 21 Sep 2011 at 4:53am
I searched around and found this as the most related, but it was too different from my case (as far as I could see) to make it work:
http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=13090&KW=running+total+header

I have several running total fields.  They are working fine, and I am aware that they work based on counting records and then being displayed at the bottom of the report.

Is there a way to take them and display them at the top?  Right now I have six running totals, and two of each are added together, to leave three formula fields:
(Total 1) = {RTotal0}+{RTotal1}
(Total 2) = {RTotal2}+{RTotal3}
(Total 3) = {RTotal4}+{RTotal5}

Any help is much appreciated.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Sep 2011 at 4:58am
RT totals can not be displayed prior to all data that is included the total being printed/read so they do not work in headers (they happen in a later data pass).
There are possible workarounds.
1. Use formula(s) and summary functions instead.
2. use sub report(s).
3 use crosstab(s)
IP IP Logged
JFinzel
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Location: United States
Online Status: Offline
Posts: 49
Quote JFinzel Replybullet Posted: 21 Sep 2011 at 6:44am
If I need a running total, how do I summarize a formula?  Looking at the past topic, I tried to create a summary but I could only summarize fields, not any of my formulas.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Sep 2011 at 7:27am
you can summarize certain formulas.
In my very limited understading is has to do with data passes and which pass an item can be (or is) created on. In a very non-technical way I think in general if the formula is created in the "while reading records pass" it can be summarized (using the insert summary function).
If teh formula is created during the 'while printing records pass' it cannot be summarized (using the insert summary function).
Examples:
if gender='Male' then 1 else 0 is created in an early enough to SUM the result (and place in a header).
change this formula doing the same calcualtion to:
whileprintingrecords;
if gender='Male' then 1 else 0
 and it can no longer be summarized.
certain formula functions inherently require they are created in later passes, like using previous() or next() so they can never be summarized (using insert summary) and therefore the results cannot be used in headers.
Does this help?
 
NOTE: there are more than 2 passes and more things happen in each pass, this is just to try and help understand the basic idea.
 


Edited by DBlank - 21 Sep 2011 at 7:30am
IP IP Logged
JFinzel
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Location: United States
Online Status: Offline
Posts: 49
Quote JFinzel Replybullet Posted: 21 Sep 2011 at 7:38am
I think I generally get what you are saying.  One of my running totals does use the previous or next function, so I probably can't do it.  I will mess around with it though and see if I can get the numbers I want with summary instead.  Thank you for the help again.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 21 Sep 2011 at 7:47am
if you post sample data and what you want to show in the header maybe someone can give you different ideas/ways to do it.
IP IP Logged
JFinzel
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Location: United States
Online Status: Offline
Posts: 49
Quote JFinzel Replybullet Posted: 21 Sep 2011 at 10:01am
My data is based on (Host) and (Guest).  It is displayed like so:

Group: (Host.Name)  (Registration.Status)
       Details: (Guest.Name)  (Registration.Status)

I am counting up "Registration.Status" for both Hosts and Guests, which have three options: "Not Registered", "Registered", "Do Not Register".

This is how I have found I have to count:

Group: (Host.Name)  (Registration.Status)
       Details: (Guest.Name)  (Registration.Status)
                    (Host.Name)   (Registration.Status) - (BOTH HIDDEN, HERE FOR COUNT)

Report Footer: Rtotal0: Count
                                      Evaluate: Guest.Registrat.Status = "Registered"
                                      Reset: Never
                        Rtotal1: Count
                                      Evaluate: Next ({HostID})<>{HostID}
                                      and Host.Registration.Status = "Registered"
                                      Reset: Never
                        Formula: {@Rtotal0}+{@Rtotal1}

      Displayed: "Total Registered: {Formula}"


I hide the running totals in the footer and just display total registered.  I do this for each of the three "Registration" options.

As you can see, I put the group name in the details so that I can running total it.  Not sure if that is problematic but it works.

Thanks for any help.


Edited by JFinzel - 21 Sep 2011 at 10:02am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 22 Sep 2011 at 3:42am
since you can't summarize directly, you can create a variable to hold the amounts so that they can be reported on later on...though you are already displaying this in the report footer (or at least that is what I would supposed from the Reset:Never.
 
DBlank knows RTs much better than me.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Sep 2011 at 3:48am
I am not seeing any immediate 'simple' way to get the data into a group header.
so you are trying to get a total amopunt of people registered but you have hosts in one table and there related guests in another table. A host may have registrered guests but the host is not registered or vice versa, correct?
IP IP Logged
JFinzel
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Location: United States
Online Status: Offline
Posts: 49
Quote JFinzel Replybullet Posted: 22 Sep 2011 at 7:36am
Originally posted by DBlank

I am not seeing any immediate 'simple' way to get the data into a group header.
so you are trying to get a total amopunt of people registered but you have hosts in one table and there related guests in another table. A host may have registrered guests but the host is not registered or vice versa, correct?


Actually both the guests and hosts have to register.  Here is what the data looks like that I am doing an RT on (showing all data, including what is hidden):

John Doe (Host)  Registered
  (Detail A):  James Smith    Registered
  (Detail B):  John Doe  Registered
                    Tim Johns   Not Registered
                    John Doe  Registered
                    Janice Thomas    Do Not Register
                    John Doe Registered
                    Philip Smith  Registered
                    John Doe Registered

As you can see, John Doe (the host) repeats, and this is the one I do a (Next) formula to get the running total on.  Again, not sure if there is a better way to get that count, but it works.

And for (Detail A), I simply count the ones that are marked "Registered".

I add both RTs together to get total "Registered".  Make sense?

Is there not a way to make a summary of field (Host.Registration) to include only "Registered"?  Likewise for (Guest.Registration)?  This would solve my problem.
    

IP IP Logged
Page  of 2 Next >>
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.