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

Group total of a formula that is defined from a subreport

Status
Not open for further replies.

Deano1976

Technical User
Dec 16, 2004
41
GB
CR v8.5

I have a formula ({@Training Days}) that calculates training days based on the number of attendees and the duration of the course. This works fine
I also have the report grouped by Trainer Reference and by Course Ref so that I can see the training days for each course that the trainer has trained. I currently have a formula to calculate the training days for each Course Ref, but I need to be able to sum these training days to get a sum for all the trainer's courses in the Trainer Ref group. The formula's I currently have are below and are all in the Course Ref group along with any appropriate subreports.

Code:
[b]{@days}[/b] = 
datediff("d",{EVENT.STARTTIME},{EVENT.FINISHTIME})
[b]{@hours}[/b] = 
if ((datediff("h",",{EVENT.STARTTIME},{EVENT.FINISHTIME})/24) <=0.13) then 0.5
else 1
[b]{@MainFormula(Attended)}[/b] = 
WhilePrintingRecords;
Shared NumberVar EmployeeCount;
EmployeeCount;
[b]{@Training Days}[/b]
if {EVENT.COMPLETED} = "T" then ({@days}+{@hours})*{@MainFormula(Attended)}
else 0
 
Not sure where any of these formulas are, so I'll just pass along theory.

If you want the total of some aggragate that's in a group, you'll need an additional variable to sum those.

For instance to sum a field for use by the main report, but is aggregated in a subreport, place the following in the subreport in the appropriate section:


WhilePrintingRecords;
Shared NumberVar TotalCount:=TotalCount+{@someformula}

now you can display it in the main report using:

WhilePrintingRecords;
Shared NumberVar TotalCount

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top