Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Subreport-Summaries-Formulas Post Reply Post New Topic
Author Message
sl@ja
Newbie
Newbie
Avatar

Joined: 11 May 2009
Location: United States
Online Status: Offline
Posts: 8
Quote sl@ja Replybullet Topic: Subreport-Summaries-Formulas
    Posted: 22 May 2009 at 1:05pm
I'm currently designing a data feed that will export to a text file.  One part of the feed deals with financial information.  In that section, I'm using a subreport because I need to present several rows of information, grouped by paycode.  Basically, I need the results in this section to look like this:

{paycode} {totalreserved$$-totalpaid$$} {totalpaid$$}
{paycode} {totalreserved$$-totalpaid$$} {totalpaid$$}
{paycode} {totalreserved$$-totalpaid$$} {totalpaid$$}

Each paycode has multiple reserves and payments that need to be totaled to go in the line above.  Sometimes, though there will be reserves but no payments for a particular paycode.  For example, in the reserve table, I'll have:

{paycode} {reserve}
02               $312
02               $221
06               $106
06               $44
21               $57

In the payment table, I'll have:

{paycode} {payment}
02               $53
02               $37
06               $21
06               $12

I'm able to get a total of the reserves, but I can't make it subtract a total of the payments to give me what's left reserved without it returning gibberish.  And then if I could ever make it get that, how would I make the next field be a total of the payments without the summary impacting the one in the previous formula.  Help?

Advance thanks!!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 26 May 2009 at 6:53am
I would use shared variables (big surprise, I say it just about every post).  Running totals might work, but I like variables.
 
Since you are basically only displaying the subtotal when grouping by {paycode}, in the group header I would set the variable to 0, in the detail section I would add to the reserve the values that are reserves and likewise for the payments, and in the group footer, I would have a formula to calculate the difference and one to report the payments.  Sounds simple.  For this to work as well, it would seem that you would need to do a full outer join on the payment and the reserve tables based on paycode, and in the formula to increment, you would only increment if the value is not null (means that a match could not be found in the other table).  If there are always more or the same number of reserves than payments, a left join to reserves of payments would work instead of the full join.
 
if you were getting this from stored proc, you could have your data engine do all this work for you, instead of crystal and then you might not need the subreport or all these formulas.
 
HTH
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.