Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Formula/Selection Issues Post Reply Post New Topic
Page  of 2 Next >>
Author Message
sl@ja
Newbie
Newbie
Avatar

Joined: 11 May 2009
Location: United States
Online Status: Offline
Posts: 8
Quote sl@ja Replybullet Topic: Formula/Selection Issues
     Posted: 11 May 2009 at 1:33pm
Hello all--

Thanks in advance to anyone who can help me. 

My issue is this - I have two tables containing financial information, Reserve and Payment.  Both tables contain an amount field and a pay code field.  I need to find some way to summarize data in these two reports, but only when the pay codes match.  For example, I need this (but in formula form)

When Reserve.pay_cd =1 and Payment.pay_cd =1, (sum(Reserve.amt)-sum(Payment.amt))

I have to do this for multiple pay codes within the same report. 

I've tried several variations on a formula for this, but none of them return the correct results so I thought I'd try to see if the real experts (all of you) knew something else I could try.

Thank you!




Edited by sl@ja - 11 May 2009 at 1:45pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 11 May 2009 at 2:26pm
Can you post a little sample data as it appears after you join the two tables?
IP IP Logged
sl@ja
Newbie
Newbie
Avatar

Joined: 11 May 2009
Location: United States
Online Status: Offline
Posts: 8
Quote sl@ja Replybullet Posted: 12 May 2009 at 9:08am
What sort of data would be helpful?  The incorrect results I receive or exactly what I'm looking for?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 May 2009 at 9:27am
Both would be useful. I would need to understand how the raw data looks and then what you want it to end up as.
IP IP Logged
sl@ja
Newbie
Newbie
Avatar

Joined: 11 May 2009
Location: United States
Online Status: Offline
Posts: 8
Quote sl@ja Replybullet Posted: 12 May 2009 at 9:58am
RESERVE TABLE

claim_id pay_cd reserve_amt
1 1 10
1 1 25
1 2 15
1 2 30
1 3 45
1 3 65
1 3 5
1 4 80
1 4 5








PAYMENT TABLE

claim_id pay_cd payment_amt
1 1 5
1 1 10
1 2 15
1 2 20
1 3 25
1 3 30
1 3 35
1 4 40
1 4 45

This is representative of what the data looks like in the database.  I need a way to take the reserve amounts with a pay code of 1 (10 & 25), sum them, and then subtract from them the payment amounts with the same pay code (5 & 10) so that my result is, basically, (10+25)-(5+10).   And then I need to do that with each subsequent paycode.

Right now, if I get any result at all, it's typically that I'm getting the sum of multiple pay codes (result sums pay codes 1 & 2, for example, but doesn't include 3) or I get some number that ends up being a multiple of the actual reserve amount.  I've also tried using running totals to total the payments and reserves separately (using the formula (table,field).pay_cd = 1 in the "evaluate" section) and then using a formula to find the difference between the two running totals, but I end up with the same results.

Does this help?  I'm sorry - I've never really used Crystal before in this capacity.  Most of the reporting I've done has been quite simple.  I used to work with a developer, but he's since moved on and I haven't had the time to advertise for someone new.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 May 2009 at 10:10am
How are you joining these tables together? On claimid or something else?
I think that may be a key issue in creating duplicate records that will mess up any calcualtions...
You may ultimately have to create sub reports and pass the values back to the main report and sum those.
Anyone else seeing a solution?
IP IP Logged
sl@ja
Newbie
Newbie
Avatar

Joined: 11 May 2009
Location: United States
Online Status: Offline
Posts: 8
Quote sl@ja Replybullet Posted: 12 May 2009 at 10:17am
Actually, I'm using a subreport, linked to the main report by claim_id.  Now that you mention it, maybe I should just go ahead and work towards passing the values I get from the formulas within the subreports back to the main rather than trying to get the formulas within the subreport to work.  I've gotten the totals of the payments by paycode within one subreport and the totals of the reserves by paycode within another subreport to work.  Maybe I should just try to use formulas within the main report to find the difference between variables I've assigned values to in the subreports?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 12 May 2009 at 10:36am
That seems like the most reasonable solution since you already have it set up that way.
IP IP Logged
sl@ja
Newbie
Newbie
Avatar

Joined: 11 May 2009
Location: United States
Online Status: Offline
Posts: 8
Quote sl@ja Replybullet Posted: 12 May 2009 at 10:43am
I'm sure I can either figure out how to do that or find the steps to do so since it's such a specific (and probably common) thing to do.  Thank you so much for your help.  You've saved me yet more hours trying to figure out how to do this in a way that I don't think was ever really going to work.
IP IP Logged
sl@ja
Newbie
Newbie
Avatar

Joined: 11 May 2009
Location: United States
Online Status: Offline
Posts: 8
Quote sl@ja Replybullet Posted: 12 May 2009 at 12:56pm
One more question - I've gotten the values passing back from the subreports and incorporated them in formulas that are giving the correct results, but they're showing on the line below where I need them.  For example, I need a result for claim #1, but the correct result for it is showing up on claim #2.  Is there a simple explanation for what I'm doing wrong?  
IP IP Logged
Page  of 2 Next >>
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