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!

displaying Differences between averages formula

Status
Not open for further replies.

CromwellF

Technical User
Dec 21, 2004
8
GB
I have a collection of data that is grouped against dates. For these dates I need to return the averages of the data related to date. This I can do quite happily, however as the dates increase through the range reported against I also need to output of the difference between the first date average and the second date average, then 2nd and 3rd and so on.
 
Create three formulas:

//{@reset} to be placed in the group (date) header_b section (insert this section and then suppress it):
whileprintingrecords;
numbervar sumamt := 0;
numbervar prevave := 0;
numbervar counter := 0;

//{@prevave} to be placed in the detail section:
whileprintingrecords;
numbervar sumamt := sumamt + {table.amount};
numbervar counter := counter + 1;
numbervar prevave;

prevave := sumamt/counter

//{@diff} to be placed in the group header_a section:
whileprintingrecords;
numbervar prevave;

prevave - average({table.amount},{table.date})

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top