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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subreport and Main Report Calculations

Status
Not open for further replies.

donnarenia

Technical User
May 28, 2010
41
US
Can I take a Total from a Subreport and subtract it from a total on the main report?

For Example: I have a main report that calculates Invoice amounts based on the invoice date ..i.e.5/1/2010 - 5/30/2010 and those invoices total $55,823.73.

My subreport calculates the adjustments applied to invoices within that date range but based on the Adjustment Received Date...i.e. Date Received...5/1/2010 - 5/30/201 and the adjustments within that range totals $10,931.02.

How can I subtract $10,931.02 (from the subreport) from the 55,823.73 (from the Main Report)?
 
In your subreport, use a Shared variable.
e.g. Shared NumberVar adjust := Sum({YourTable.YourAdjustmentField})

In the main report, create a formula that will use this Shared variable along with the main report's total.

e.g.
Shared NumberVar adjust ;
Sum(YourTable.YourInvoiceField) - adjust

Bob Suruncle
 
Thanks that worked! Thanks..

However, to follow- up with that...I have the formula

THIS IS IN MY MAIN REPORT
WhilePrintingRecords;
Shared NumberVar adjust ;
Sum ({@commission}, {CLNTCUS.~Custom3}) - adjust

THIS IS IN MY SUB REPORT

WhilePrintingRecords;
Shared NumberVar adjust := Sum
{@commission},CLNTCUS.~Custom3})

These formulas give me a total of my adjustments for my subreport and the total of my Adjustments on my main report...Perfect!

Now how can I subtract the two and show that amount at the bottom of the report?

for instance... MAIN REPORT ADJUSMENT TOTAL = 19538.31
SUB REPORT ADJUSTMENT TOTAL = 3825.86

How can I subtract these two variables to = 15712.45
 
I got it!!!!! Not exactly sure how but the caluclation worked when I moved the formula into my Group Footer below my sub report ....Thanks for your help! I love this Forum!
 
Right. Because Crystal processes from top to bottom, the formula to read the value from the subreport MUST be in a report section that comes after the section where the subreport is located.
Cheers

Bob Suruncle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top