Copy link to clipboard
Copied
Looking for a Document level script and Field level script that will ignore blanks in the average but will count 0s in the average. I have several fields for subaverages and a cumulaitve average. I have been using these two scripts to ignore blanks but now they want the 0s in the averages. Any suggestions would help!
function calcAverage(fields, ignoreBlanks) {
var total = "";
var n = "";
for (var i in fields) {
var f = this.getField(fields[i]);
if (f==null) {
console.println("Error! Can't locate a field called: " + fields[i]);
continue;
}
if (f.valueAsString=="" && ignoreBlanks) continue;
total+=Number(f.valueAsString);
n++;
}
if (n=="") event.value = "";
else event.value = total/n;
}
calcAverage(["PLO_1_a", "PLO_1_b", "PLO_1_c", "PLO_1_d", "PLO_1_e"], true, true);
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Tried that and it's still not working. Any other suggestions?
Copy link to clipboard
Copied