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

Manual running total formula

Status
Not open for further replies.

ajhess

Technical User
Jul 27, 2012
18
US
I'm trying to write a manual running total formula in a Subreport to get a Year-to-Date value for each 'Cost Center' that I can pass to the Main report. Below is what I have so far, and it works OK except in the case where the Main Report has a 'Cost Center' value that does not exist on the Subreport... in these cases the formula incorrectly uses the value from the preceding cost center.

numbervar Month1Value;
numbervar Month2Value;
numbervar Month3Value;
numbervar Month4Value;
numbervar Month5Value;
numbervar Month6Value;
numbervar Month7Value;
numbervar Month8Value;
numbervar Month9Value;
numbervar Month10Value;
numbervar Month11Value;
numbervar Month12Value;

if {T_STATISTIC_INPUT.DataSetID} startswith "ACTUAL"
then select {T_STATISTIC_INPUT.MonthNumber}
case 1 : Month1Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 2 : Month2Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 3 : Month3Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 4 : Month4Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 5 : Month5Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 6 : Month6Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 7 : Month7Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 8 : Month8Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 9 : Month9Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 10 : Month10Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 11 : Month11Value := tonumber ({T_STATISTIC_INPUT.MthValue})
case 12 : Month12Value := tonumber ({T_STATISTIC_INPUT.MthValue});

whileprintingrecords;
shared numbervar YTD_Actual_Paid_Hours := (Month1Value + Month2Value + Month3Value + Month4Value + Month5Value + Month6Value + Month7Value + Month8Value + Month9Value + Month10Value + Month11Value + Month12Value)


I place this formula in the Details section of the subreport, as well as Group Footer 1 which is by 'Cost Center'

In the main report I have the Subreport in the Details section, and call the shared variable in this formula...
whileprintingrecords;
shared numbervar YTD_Actual_VolumeStat;


I place the formula in Group Footer 1, which is by Cost Center. Again, it works unless the main report has a Cost Center which does not exist in the subreport, in which case the preceding cost center value is used.

Any help is greatly appreciated, thank you
Andrew
 
You will need to reset the variables to zero. Not certain I fully understand the structure of your report, but my guess is you should do it in the Report Header of the sub-report with a formula like this:

Code:
WhilePrintingRecords;
numbervar Month1Value := 0;
numbervar Month2Value := 0;
numbervar Month3Value := 0;
numbervar Month4Value := 0;
numbervar Month5Value := 0;
numbervar Month6Value := 0;
numbervar Month7Value := 0;
numbervar Month8Value := 0;
numbervar Month9Value := 0;
numbervar Month10Value := 0;
numbervar Month11Value := 0;
numbervar Month12Value := 0;


Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top