AVERAGEIF
function AVERAGEIF(arg1: ApiRange = null, arg2: number | string = null, arg3: ApiRange = null): number
Description
Finds the average (arithmetic mean) for the cells specified by a given condition or criteria.
Parameters
The range of cells which will be evaluated.
- arg2
number | string
null The condition or criteria in the form of a number, expression, or text that defines which cells will be used to find the average.
The actual cells to be used to find the average. If omitted, the cells in the range are used.
Returns
number
Try It
var oWorksheet = Api.GetActiveSheet();
var oFunction = Api.GetWorksheetFunction();
var numbers = [67, 87, 98, 45];
for (var i = 0; i < numbers.length; i++) {
oWorksheet.GetRange("A" + (i + 1)).SetValue(numbers[i]);
}
var oRange = oWorksheet.GetRange("A1:A4");
oWorksheet.GetRange("C1").SetValue(oFunction.AVERAGEIF(oRange, ">45"));