
1. Re: Javascript to calculate the average
try67 Jan 30, 2016 2:58 PM (in response to gayathriv26674322)Do you have a specific question, or do you expect us to write your entire script for you?

2. Re: Javascript to calculate the average
gkaiseril Jan 31, 2016 6:45 AM (in response to gayathriv26674322)You need to create a custom calculation to sum the values and count the number of items to be used in the calculation, not all "averages" use the total number of entries, and divide the sum by the number items used or needed for computing the average as long as that number is not zero
There a number of JavaScript sites that provide user written functions for calculating various statistics.

3. Re: Javascript to calculate the average
gayathriv26674322 Jan 31, 2016 9:37 PM (in response to try67)Hi
I need the logic of the script.

4. Re: Javascript to calculate the average
gkaiseril Feb 1, 2016 7:19 AM (in response to gayathriv26674322)You place the value of the fields to be used in the average into an array. Next filter out unwanted data element if needed, like empty elements. Now sum the elements of the array. Divide the sum of the elements in the array by the number of items in the array and assign the result to the field for the result;
A function like will compute the average of the values in an array of values.
function average(data){
// computes the average of the values within an array;
var sum = data.reduce(function(sum, value){
return sum + value;
}, 0);
var avg = sum / data.length;
return avg;
} // end function average;
The above is the JavaScript syntax for the computation. I assume you understand how to get field values and add the values to an arraty. If needed you can use the array filter method or prototype to remove unwanted data elements.