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!

Summing an average for an additional group

Status
Not open for further replies.

makeitwork09

Technical User
Sep 28, 2009
170
US
Two years ago I posted this -
With the help provided, I was able to get the report working as requested. Today, two years later, an additional group was asked to be added to report. Unfortunately, because I do not completely understand what was happening with the solution provided, I am not sure how to handle the new group.

With the new request we moved from
GROUP 1 - Allowance Type - this is a sum of the property type averages at the allowance level
GROUP 2 - Investor - this is she sum of the property type averages at the investor level
GROUP 3 - Property Type - this is the average mentioned in the post listed above

to

GROUP 1 - Loan Kind - I am not sure how to do a sum of the property type averages at this levelGROUP 2 - Allowance Type - this is a sum of the property type averages at the allowance level
GROUP 3 - Investor - this is she sum of the property type averages at the investor level
GROUP 4 - Property Type - this is the average mentioned in the post listed above

Below are the current formulas for the displays:
Code:
//accum for the property information
whileprintingrecords;

numbervar curr;
numbervar prev := curr;
numbervar cnt;
numbervar sumave;
numbervar ave;

curr := Sum ({@SV}, {COMPHIST.ACCOUNTING_DATE}, "monthly");

if 
(DistinctCount ({COMPHIST.ACCOUNTING_DATE}, {@TYPE/ACLI}) = 1 and
Minimum ({COMPHIST.ACCOUNTING_DATE}, {@TYPE/ACLI}) = {@AVG PREVIOUS DATE UPDATE})
then (
     cnt := cnt + 1;
     ave := curr
)else if

Minimum ({COMPHIST.ACCOUNTING_DATE}, {@TYPE/ACLI}) <> {@AVG PREVIOUS DATE UPDATE}
then (
     cnt := cnt + 1;
     ave := (curr+prev)/2
)else
(
     cnt := 0;
     ave := 0
);
sumave := sumave + ave; //sums the property type averages
ave;
Code:
//Group 3 - Propery Type
whileprintingrecords;

numbervar sumave;
numbervar cnt;
numbervar cnt2;
numbervar grp2ave;
numbervar grp1sum;

if cnt <> 0 then 
grp2ave := sumave/cnt;

if grp2ave <> 0 then
cnt2 := cnt2 + 1;

grp1sum := grp1sum + grp2ave;

grp2ave;
Code:
//Group 2 - Investor
whileprintingrecords;

numbervar grp1sum;
numbervar cnt2;
numbervar grandsum;
numbervar grpallow;
numbervar cntall;
numbervar grp1ave;
numbervar grpkind;


if cnt2 <> 0 then 
grp1ave := grp1sum/cnt2;

grandsum := grandsum + grp1sum;
grpallow := grpallow + grp1sum;

if grp1ave <> 0 then
cntall := cntall + 1;
grp1sum;
Code:
//Group 1 - Allowance
whileprintingrecords;

numbervar grpallow;

grpallow;

Thanks in advance for the assistance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top