Skip to main content

AVERAGE

Returns the average (arithmetic mean) of the specified arguments.

Syntax

expression.AVERAGE(args);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
argsRequiredApiRange | ApiName | number | number[]Up to 255 numeric values for which the average value will be returned. The first argument is required, subsequent arguments are optional. Arguments can be numbers, names, or arrays of numbers.

Returns

number

Example

Calculate the arithmetic mean of a set of numbers in a spreadsheet.

// Find the average of several values in a spreadsheet.

// Add up all numbers and divide by their count to get a central value in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
let ans = func.AVERAGE(123, 197, 46, 345, 67, 456);
worksheet.GetRange("B2").SetValue(ans);