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((lvgroups100)/lv12mosum,"##.#")+"%)"+cr()+cr()+“From individuals is: “+pattern(lvindividuals,”$#,.##”)+" ("+pattern((lvindividuals100)/lv12mosum,"##.#")+"%)"
closewindow
beep