I wrote a procedure which is designed to display three values: a total 12 mo average, the 12 mo average for groups with the percentage of the total of those groups; and the 12 mo average for individuals with the percentage of the total for those individuals.

The following procedure returns the correct value for the total 12 mo average every time. One time it is run, the 12 mo average for groups is correct, but the 12 mo average for individuals is incorrect. The next time the procedure is run, the 12 mo average for the groups is incorrect, but the 12 mo average for individuals is correct. It oscillates back and forth. What is causing that? I can not figure it out.

local lv12mosum, lvgroups, lvindividuals

opensheet

selectall

field Â«12mosumÂ»

total

lastrecord

copycell

lv12mosum=val(clipboard())/12

removesummaries 7

selectall

field Â«typeÂ»

select Â«typeÂ»=â€śgroupâ€ť

field Â«12mosumÂ»

total

lastrecord

copycell

lvgroups=val(clipboard())/12

removesummaries 7

selectall

field Â«typeÂ»

select Â«typeÂ»=â€śindividualâ€ť

field Â«12mosumÂ»

total

lastrecord

copycell

lvindividuals=val(clipboard())/12

removesummaries 7

selectall

message â€śThe 12moave is: â€ś+pattern(lv12mosum,â€ť$#,.##â€ť)+cr()+cr()+â€śFrom groups: â€ś+pattern(lvgroups,â€ť$#,.##â€ť)+" ("+pattern((lvgroups*100)/lv12mosum,"##.#")+"%)"+cr()+cr()+â€śFrom individuals is: â€ś+pattern(lvindividuals,â€ť$#,.##â€ť)+" ("+pattern((lvindividuals*100)/lv12mosum,"##.#")+"%)"

closewindow

beep