Skip to main content

HARMEAN

Returns the harmonic mean of a data set of positive numbers: the reciprocal of the arithmetic mean of reciprocals.

Syntax

expression.HARMEAN(args);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
argsRequiredApiRange | number[] | ApiNameUp to 255 numeric values for which the harmonic mean will be calculated. Arguments can be numbers, names, ranges, or arrays of numbers.

Returns

number

Example

Return the harmonic mean of a data set of positive numbers: the reciprocal of the arithmetic mean of reciprocals in a spreadsheet.

// How to calculate the harmonic mean of a data set of positive numbers in a spreadsheet.

// Use a function to calculate harmonic mean in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
let ans = func.HARMEAN(28, 16, 878, 800, 1650, 2000);
worksheet.GetRange("B2").SetValue(ans);