Zeros are included in average calculation
<p>Have a set of averages (12 with two groups) that are calculated (whole number) with a javascript. The script doesn't count zero or blanks. Works fine for whole number.</p>

<p>These averages are carried over to a summary page with two rows like so:</p>

<pre><code>CCA1, CCA2, CCA3, CCA4, CCA5, CCA6, CCA7 = CCA_COMBINED_AVG
JCA8, JCA9, JCA10, JCA11, JCA12          = JCA_COMBINED_AVG
</code></pre>

<p>The following jacascript is calculating zeros or blanks:</p>

<pre><code>function myAverageFunction(aNames) {
    // n = number of fields that have a numerical value
    // sum = some of values for the named fields
    var n = 0;
    var sum = 0;
    var v;
    // loop through array of name strings
    for (i = 0; i &lt; aNames.length; i++) {
      v = this.getField(aNames[i]).valueAsString;
      // check for not a null string and not a space  and not is Not a Number
      if (v != "" &amp; v != " " &amp; isNaN(v) == false) {
         n++; // increment count
         sum += Number(v); // add to sum
      }
    }
    return (n != 0) ? (sum / n): "";
}

event.value = myAverageFunction(["CCA1", "CCA2", "CCA3", "CCA4", "CCA5", "CCA6", "CCA7"]);
</code></pre>

<hr>

<p>Any help would be appreciated.</p>
