Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Use sum from one table as field in another report. Post Reply Post New Topic
Author Message
marsol
Newbie
Newbie


Joined: 06 Oct 2008
Location: United States
Online Status: Offline
Posts: 1
Quote marsol Replybullet Topic: Use sum from one table as field in another report.
     Posted: 06 Oct 2008 at 10:03am

I'm probably making this a lot harder than it really is.  I want to create a report that shows a current balance.  One table (tableA) has beginning balance information and total charges in it.  There is one record per customer.  Another table (tableB) has daily deposits in it.  There are multiple records per customer.

I need a report that will report:
tableA.beginbalance - tableA.charges + sum(tableB.deposits)
 
In other applications this is pretty straightforward.  I don't see where I can use one report as a datasource for another report.
 
Do I use a subreport?
 
Mark
IP IP Logged
saoco77
Senior Member
Senior Member


Joined: 26 Jun 2007
Online Status: Offline
Posts: 104
Quote saoco77 Replybullet Posted: 06 Oct 2008 at 4:49pm
I think you should be able to do this without subreports. Have you tried adding both tables to the same report and then doing the calculation?

1) Add both tables to the report. Check the links between tables - most likely needs to be a left outter join on the customerID.

2) Group by tableB.customer
3) Create a formula similar to this.

({tableA.beginbalance} - {tableA.charges}) +
sum({tableB.deposits},{tableB.customer})

4) Place the formula in the group header or footer. This should give you an account balance by customer

I think this will work but I haven't tested it.

Sarah

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