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

Passed Subreport Values - Possible to Sum

Status
Not open for further replies.

IceRuby

Technical User
Jan 20, 2004
85
AU
Hello there

My report consists of three groupings:-
TYPE (E.G. revenue/expense - Group#1)
CATEGORY (Subtitle group#1 e.g. Bike Sales- Group #2)
CATEGORY GROUP DETAILED (e.g. Malvern Star-Group#3)

Actual values are calculated within Main report and Budget values are passed via sharednumbervar from subreport.
Is it possible to add the subreport values within the main report as detailed below?

The subreport is linked via the formula defining setup of group#3, and the required sum value would be at group#1.

A Variance (actual-budget) column has been calculated via formula, als


e.g.
(subrprt (formula)
values) (act-getsubrprt val)
(GRP#1)REVENUE Actual Budget Variance
(GRP#2) BIKE SALES
(GRP#3) Malvern Star $200 $300 -$100
(GRP#3) Mountain Bikes $100 $500 -$400
(GRP#2) COST OF GOODS SOLD
(GRP#3) Expenses -$100 -$100 $0

(GRP#1)TOTAL $200 $700** -$500**

**These are values I need to calculate!!

Thanks in advance
 
Use the 3 formula method:

In GH1 place a formula:
whileprintingrecords;
numbervar SubSum:=0;

If the GF3 place the following formula:
whileprintingrecords;
shared numbervar SubRepValue;
// Replace the SubRepValue with whatever value you return
// from the subreport
numbervar SubSum;
SubSum:=SubSum+SubRepValue;
// Now you have the sum

In GF1 place:
In GH1 place a formula:
whileprintingrecords;
numbervar SubSum;
SubSum

-k
 
Hi and thanks very much for your response. Works great!!
Just one more question please.

It is summing the values in to Grp#1 (just as wanted), I now need to net off these Grp#1 totals. Is this possible? (see e.g. below)


(subrprt (formula)
values) (act-getsubrprt val)
(GRP#1)REVENUE Actual Budget Variance
.......................
(GRP#1)NET REVENUE $200 $700* -$500
*calculated field in main report

(GRP#1)EXPENSES
...................
(GRP#1)TOTAL EXPENSES $100 $400 -$300

(REPORT FOOTER)NET PROFIT $100 $300** -$200
** how can this field be calculated?

Thanks very much, really appreciate your help
 
Since this is based on the group name, you'll need a conditional to handle this, such as:

In the GF3 place the following formula:
whileprintingrecords;
shared numbervar SubRepValue;
// Replace the SubRepValue with whatever value you return
// from the subreport
numbervar SubSum;
SubSum:=SubSum+SubRepValue;
// Now you have the sum
If {table.group} = "Expenses" then
NetSum := NetSum -Subsum
else
NetSum := NetSum +Subsum;

Now the NetSum is also available at the end of the report for a formula.

In Report Footer place a formula:
whileprintingrecords;
numbervar NetSum;
NetSum

-k
 
Sorry to trouble you again but am having problems with this one.

I had to declare numbervar for Netsum and have included it in the same formula as Subsum. Looks like:-

whileprintingrecords;
shared numbervar TotalBudget;
numbervar SubSum;
numbervar netsum;
SubSum:=SubSum+{@gettotalfromsub};
if GroupName ({@Level 0}) = "Overheads" then
netsum:= netsum - subsum else
netsum:= netsum + subsum


GroupName ({@level 0}} grouping formula applied to define Revenue, Overheads (GRP#1 title)

Thanks once again
 
sorry was interupted and forgot to add the result I am getting is $18million should be less than $100k.

I tried declaring in separate formula but resulted in error.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top