Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Summing problem Post Reply Post New Topic
<< Prev Page  of 2
Author Message
grego
Newbie
Newbie
Avatar

Joined: 22 Feb 2008
Location: United Kingdom
Online Status: Offline
Posts: 16
Quote grego Replybullet Posted: 24 Mar 2009 at 1:49am

After checking the report I decided that the grouping by counterparty name was not needed so I deleted it.  So I have kept the reset in the group header, the jet fuel formula in the details and the sum of jet fuel  in the report footer.

 
You mentioned adding another shared variable - I'm not very good with these variable things and don't really understand how it all works I'm afraid!  Where would I add this extra shared variable and what would it look like
 
Thanks for your patience and help on this!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 24 Mar 2009 at 6:23am
The easiest way would be to add a another line in the formula in the detail section, say groupJetFuel, whatever you add to totalJetFuel add to groupJetFuel.
 
Change the reset formula to refer to groupJetFuel, create a new formula to display the groupJetFuel variable, and place it in the group footer.
 
Since you want to see totalJetFuel in the report footer, what happens if you reset the value to 0 in the group header and the variable is not updated in the details?  The totalJetFuel as it stands right now, is constantly being reset to 0 and so is not the total of the report, just of the last group...which wouldn't seem correct for where it is placed.  The changes described, allow the total by group to be displayed corrected and since the totalJetFuel := 0 is gone (replaced by groupJetFuel) the value at the end of the report is the totalJetFuel for all details on the report.
 
Does that make sense?  Hopefully it does;)
IP IP Logged
grego
Newbie
Newbie
Avatar

Joined: 22 Feb 2008
Location: United Kingdom
Online Status: Offline
Posts: 16
Quote grego Replybullet Posted: 20 Apr 2009 at 2:21am
Thanks for your help on this - I've been away on holiday and am back in trying to sort this problem again!  I think I must be missing something though!
 
I've added in the additional shared variable - so that the jet fuel formula now looks like this:
 
shared numbervar totalJetFuel;
shared numbervar GroupJetFuel;
local numbervar thisJet;
if {CPARTY.CODE} = "CHAS GP" then thisJet := -34.1 else
  if {CPARTY.CODE} = "MSLN" then thisJet := -28.1 else
   if {CPARTY.CODE} = "GSIL GP" then thisJet := -46.1 else
    if {CPARTY.CODE} = "BARC GP" then thisJet := -4.6 else
     if {CPARTY.CODE} = "CALY GP" then thisJet := -1.6 else
        if {CPARTY.CODE} = "SCBL" then thisJet := -1.5 else
           if {CPARTY.CODE} = "BNPA GP" then thisJet := -0.9;
 
totalJetFuel := totalJetFuel + thisJet;
GroupJetFuel:= totaljetfuel + thisJet;
 
 
I have added a formula to the group footer that has the following in it:
 
shared numbervar GroupJetFuel;
 
I have changed the totaljetfuel reset formula in the group header to reference GroupJetFuel as follows:
 
shared numbervar GroupJetFuel := 0;
""
(NB there is now no reset for totalJetFuel)
 
 
The number that is returned in the group footer for the sharednumbervar GroupJetFuel isn't correct.
 
Against {CPARTY.CODE} = "BARC GP" then thisJet := -4.6 - this is the first counterparty alphabetically that has jet fuel - so I would expect the sharednumbervar GroupJetFuel to = -4.6 - it equals -1,504.2 and I can't figure out where this has come from!
 
Also if if I want to actually show the jetfuel total for each counterparty in the group footer I thought all I would need to do is add a formula with the following:
 
local numbervar thisJet;
 
However when I do this I just get a 0.00 value returned against all counterparties.  I thought I might need to make the variable a shared one in the jetfuel formula to pick it up - but this didn't work either - do I need to explicitly state that I want the thisjet bit of the jetfuel formula? and if so how do I do this?!
 
thanks for continued help on this!Smile
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 20 Apr 2009 at 6:23am
the formulas listed look right.  rather than looking at the group footer, I would look at value of jet fuel formula in the detail, and at the same time the group footer of GroupJetFuel.  By doing this, you can see what the values are being set to, and if they agree with what you expect.
 
The local variables, would have to be declared in that formula, the rest of Crystal can't see them.  Since thisJet is local in the formula, it is 0 as a shared variable...you would need to set them as shared in both formulas
 
IP IP Logged
<< Prev Page  of 2
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.