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

How can I display the total of two sub-reports on main report 4

Status
Not open for further replies.

jcl5

IS-IT--Management
Dec 6, 2002
89
GB
Hi guys

I'm working with CR10 and Oracle 8i

I have a main report with two sub-reports. Each sub-report has a summary total in the report footer. I need to add together the two summary totals on the sub-reports and display the total in the main report.

Is this possible?

Thanks

jcl5
 
i've not done 2 subreport numbers to main but i've done one and then used it on the main report in a percentage to the total. i got the total on the sub report and passed it to the main report so i could then divide the detail level to the total to get my percentage.
here is the directions i used to pass the varable to the main report. it should work for 2 different reports. hope this helps
jill messier
jillm@ccc24k.com
Computer Control Corp

shared varable from sub report to main report
create your report and do your totals etc. then create formulas that share like below then save and bring into main report as a sub report
WhilePrintingRecords;
Shared numbervar shsale:= Sum ({@SalesDlr})

then place your subreport into the report headerA and surpress.
insert a report headerB and create another shared formula variable. Like below
GRAND TOTAL FORMULA =
WhilePrintingRecords; Shared numbervar shsale;shsale

WhilePrinting Records semi colon then shared numbervar or char semi colon the variable name must be the same as in the subreport semi colon and the name again.

You can not SUPRRESS or HIDE these report headers you must format them. Go to format section and check off the last box for each header.
this box is labeled,"underlay following section" This hide the section behide another.
If you need to use the header page for the report then just make the font color white.
Now GrandTotal is useable for formulas to do a percentage and sorts and then do a count if you only want to show the top 20% records.
 
You would do this using shared variables

create a formula in each subreport

1st Subreport
//@Total
WhilePrintingRecords;

Shared NumberVar Sub1Total := {Your Total Field};

2nd subreport
//@Total
WhilePrintingRecords;

Shared NumberVar Sub2Total := {Your Total Field};

Then in your main report create a formula to add the totals together

//@SubTotal
WhilePrintingRecords
Shared Numbervar Sub1Total;
Shared NumberVar Sub2Total;

Sub1Total + Sub2Total

Place the @SubTotal formula on your report, you must place the formula in a section below the section containing the sub reports for this to work.

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
This has done exactly what I wanted.
Now, I thought I could do the same to calculate a percentage. The sub-report values appear ok on the main report and when I add them together I get the correct result so I'm pretty sure these formulas are ok. However, when I try to divide I get an error message saying "Division by Zero". The formula used is:

//@subtotal
WhilePrintingRecords;
Shared NumberVar Sub1Total;
Shared NumberVar Sub2Total;

Sub1Total / Sub2Total

(sub1total returns 16, sub2total returns 65)

Any ideas what I'm doing wrong?

Thanks

jcl5
 
I don't think you have told us yet where you have these subreports placed. If they are in group footers, then you might have a denominator value = 0 somewhere. You could try:

WhilePrintingRecords;
Shared NumberVar Sub1Total;
Shared NumberVar Sub2Total;

if Sub2Total <> 0 then
Sub1Total / Sub2Total else 0

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top