Averages in Adobe Acrobat X Pro


hi all,

 

i using adobe acrobat x pro create employee performance survey, against 6 competencies employees rated 1-5 or n/o if competency not observed. have used average calculation box work out overall average each employee. however, if "n/o" selected adobe takes "0" , still calculated average out of 6 rather 5. there way tell adobe "n/o" selected not count value , take average numerical score assigned competency.

 

thanks,

carla

you have write custom calculation script perform calculation since built-in mean average calculation assumes fields used in calculation , field no data or null value treated 0 value.

 

since counting , summing common task , used in calculation of mean use 3 functions, count, sum , division calculate mean , exclude 0 values.

 

function sum() {
// compute sum of passed non-blank arguments
// input function's call arguments
// returns: sum of the  non-null vlaues
var sum = 0;
var value = "";
// loop through passed arguemnts
for (i = 0; < arguments.length; i++) {
if (arguments[i].tostring()  != "")  {
value = number(arguments[i]);
if(isnan(value) == false) {
// eliminate not number type of values
sum += number(arguments[i]); // add numeric value sum
} // end sum numbers
} // end numeric test
} // end argument loop
return sum;
} // end sum function

function count() {
// compute count  of passed non-blank arguments
// input function's call arguments
// returns: count of non-null vlaues
var count = 0;
var value = "";
// loop through passed arguemnts
for (i = 0; < arguments.length; i++) {
if (arguments[i].tostring()  != "")  {
value = number(arguments[i]);
if(isnan(value) == false) {
// eliminate not number type of values
count++; // increment count
} // end count numbers
} // end numeric test
} // end argument loop
return count;
} // end sum function

function avg(ncount, nsum) {
// compute average of passed non-blank arguments
// input: item count , sum of values
// returns: average on non-blank values or 0
// computge average if count non-zero value
if (ncount != 0) return (nsum / ncount); // return average
else return 0;
}

// values process
var total1 = this.getfield('x').valueasstring;
var total2 = this.getfield('y').valueasstring;
var total3 = this.getfield('z').valueasstring;
event.value = avg(count(total1, total2, total3), sum(total1, total2, total3));



More discussions in PDF Forms


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

After Effect warning: A problem occurred when processing OpenGL commands

Preconditions Failed. - Joomla! Forum - community, help and support