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!

need a way to sum a formula based on a summary

Status
Not open for further replies.

johnjrd

MIS
Jun 6, 2001
54
GB
Is there a way i can sum the value of a formula for a group.

I need to sum a formula which is working out the Date Difference in weeks. So ive created a formula which collects the minimum and maximum dates and then used the DateDiff function to work out the number of weeks between the dates. However i now need to grand total the number of weeks for the whole report but it seems i cant do this as ive already done a summary for the min and max dates.

Is there a way round this.

so far i have these formulas

@maxdate (this gets me the max date for a particular group)
Maximum ({sessions.sesdate},{course.csesid})

@mindate (this gets me the min date for a particular group)
Minimum ({sessions.sesdate},{course.csesid})

@differenceweeks
DateDiff ("w",{@mindate} ,{@maxdate})

i now need to sum the @differenceweeks formula for the whole report

any help would be grateful
 
Just sum the differences using a variable
@differenceweeks (placed in detail section)
WhilePrintingRecords //NB:add this to all other formulas
numbervar totalDiff;
numbervar temp;
temp := DateDiff ("w",{@mindate} ,{@maxdate});
totalDiff := totalDiff + temp;
temp;

later you would display the total difference using a formula

@displayDiff (placed in footer)
WhilePrintingRecords;
numbervar totalDiff;
"Total Difference : " + totext( totalDiff);

Have a reset formula placed to initialze the variable to zero
placed in the group header

@initialize (in Group header (suppressed)
WhilePrintingRecords;
numberVar totalDiff;
// to protect if you split over 2 pages
if not inrepeatedgroupheader then
totalDiff := 0;


Jim Broadbent
 
thanks for this a few minor mods for my report and it works fine.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top