ComputerNurse
MIS
CR v8.5 SQL DB
I am writing a report to calculate weight variances for 30 60 and 180 days. The formula is 100- (current weight / previous weight).
I thought I should put the weights and the dates in arrays and make comparisions. I ended up putting the weights in an array that resets the counter at each group change. I am not sure how to write the formula to evaluate the arrays only with in the group in the group.
The detail looks like this
Name Date Weight View contents (Test only)
-------- ------ ----- -------------
Jones 1/1/2004 99 Added to wtarray[1]
2/1/2004 97 Added to wtarray[2]
3/1/2004 98 Added to wtarray[3]
Smith 1/1/2004 150 Added to wtarray[1]
2/1/2004 155 Added to wtarray[2]
**I need to be able to do is take the amount in for wtarray[3] jones 98lbs and divide it by 97 wtarray[2].
Also the dates must be 30 days or else no calculation is done.
I am writing a report to calculate weight variances for 30 60 and 180 days. The formula is 100- (current weight / previous weight).
I thought I should put the weights and the dates in arrays and make comparisions. I ended up putting the weights in an array that resets the counter at each group change. I am not sure how to write the formula to evaluate the arrays only with in the group in the group.
Code:
Numbervar array wtarray;
Numbervar counter;
counter = 0;
If onfirstrecord
then counter:= 1
Else If not onfirstrecord and{Masterfile.ResidentNumber} = previous({ResidentMasterfile.ResidentNumber})
then counter := counter + 1
Else if not onfirstrecord and Masterfile.ResidentNumber} <> previous({Masterfile.ResidentNumber})
then counter := 1;
If counter <=1000
then (redim preserve wtarray[counter];
wtarray[counter]:={MR Tracking D.CurrentWeight});
Name Date Weight View contents (Test only)
-------- ------ ----- -------------
Jones 1/1/2004 99 Added to wtarray[1]
2/1/2004 97 Added to wtarray[2]
3/1/2004 98 Added to wtarray[3]
Smith 1/1/2004 150 Added to wtarray[1]
2/1/2004 155 Added to wtarray[2]
**I need to be able to do is take the amount in for wtarray[3] jones 98lbs and divide it by 97 wtarray[2].
Also the dates must be 30 days or else no calculation is done.