Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Calculation on formulas from subreports Post Reply Post New Topic
Author Message
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Topic: Calculation on formulas from subreports
     Posted: 07 May 2009 at 6:56pm
Hi All
 
This is my first post so I will try to be as straight to the point as possible. I am using Crystal XI and have created a main report with two subreports. I have successfully created shared variables on both subreports (in details section a) and have a formula to give me a total of figures (in details section b) from said subreports.  I also have a group that I want the same calculation done as in the details section. eg;
 
Group1
details      subreport      subreport       formula (subreport+subreport)
                    $100.00       $150.00         $250.00
 
I need to display a total for the group as well. I would have thought that placing the same formula that is in the details section in the group headers and footers would have worked, but no. I also had a look at global variables but that doesn't seem to help either.
 
Any suggestions would be very welcome
 
duffey01
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 08 May 2009 at 6:22am
As long as your formula for the details of Group1 is displayed after the subreport and you have unique variables for the subreports, the formula as described above should work for the details section.
 
If you want a total, you will need another variable to accumulate the values from the subreports and display it in the footer.  so you will need a formula to reset the this new variable (used in the header) and one to display it (used in the footer). Unfortunately, you can not aggregate formulas with variables.
 
From what I remember reading, Shared variables will cross the line with subreports where Globals will not...I always use shared, and don't worry about global.
 
I may be wrong, but the way that I look at Crystal is as a list.  Crystal only 'knows' something after it has read it, and it reads from the top of the report down to the bottom.  There are some exceptions to this, but in general, if I think this way, my reports always have the data that I expect in them and they 'work' as expected.
 
Hope some of this helped
IP IP Logged
duffey01
Newbie
Newbie
Avatar

Joined: 04 May 2009
Location: Australia
Online Status: Offline
Posts: 39
Quote duffey01 Replybullet Posted: 11 May 2009 at 7:14pm
Hi Lockwelle
 
If I have interpreted your reply correctly I have declared the same variables but with different names, placed the reset in GF1 & formula to add two together in GF2. I get the sum of the last record for each subreport. I am trying to think logically about this but can't get my head around it. Any suggestions?? Thanks very much in advance.
 
duffey01
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 12 May 2009 at 6:24am

OK, you reset in GF1, and add in GF2, I am assuming that the subreports are in the details?

When I need to test things like this, I write a small formula that just displays the results that I am interested in.  This way, I can 'see' what Crystal is doing and adjust my report accordingly.
 
You could add a detail section and have a couple of formula that return the sum from each sub report.  This way you can see if the values from the subreports are correct and if the sum in GF2 is correct and/or where things are not going as you think they should.
IP IP Logged
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