Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Total is not what is expected 1

Status
Not open for further replies.

infimo

Technical User
Apr 8, 2004
22
US
I have a report that uses a pair of master-detail type tables: Table A (Parent) and Table B (Child)

The schemas of these two tables is as follows:
Table A
-------
AID
AName
Cost

Table B
-------
AID
BID
BName

TableB's AID is a foreign key referencing Table A's AID

I need to display the report as follows:

AName1 Cost1
BName1
BName2
AName2 Cost2
BName3
BName4
BName5 _________
TotalCost

The problem I am having is in calculating TotalCost. Because of the way I am joining the tables, the TotalCost is coming as Cost1 * 2 + Cost2 * 3, where 2 and 3 are the number of records in B that correspond to the particular records in A.

How can I get TotalCost = Cost1 + Cost2 + ...?

Thanks a lot for your help.

Infimo
 
Are you grouping by Record A? If so, you want to accumulate Cost for each group rather than each record. This is one of the options you get with running totals; you can also evaluate when a particular field changes, or else use a formula.

To get a running total, right click and choose Insert and Running Total.

It helps to give your Crystal version, since newer versions have extra options, and some extra problems. I use Crystal 8.5.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Thanks a lot!!

Fixed my problem and opened up a wealth of new possibilities for me. I didn't know about Running Totals at all.

Infimo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top