DAVERAGE

function DAVERAGE(
  arg1: ApiRange = null,
  arg2: number = null,
  arg3: string = null,
): number | string | boolean

Description

Averages the values in a column in a list or database that match conditions you specify.

Parameters

arg1ApiRangedefault: null

Is the range of cells that makes up the list or database. A database is a list of related data.

arg2numberdefault: null

Is either the label of the column in double quotation marks or a number that represents the column's position in the list.

arg3stringdefault: null

Is the range of cells that contains the conditions you specify. The range includes a column label and one cell below the label for a condition.

Returns

number | string | boolean

Try It

var oWorksheet = Api.GetActiveSheet();
var oFunction = Api.GetWorksheetFunction();
oWorksheet.GetRange("A1").SetValue("Name");
oWorksheet.GetRange("B1").SetValue("Age");
oWorksheet.GetRange("C1").SetValue("Sales");
oWorksheet.GetRange("A2").SetValue("Alice");
oWorksheet.GetRange("B2").SetValue(20);
oWorksheet.GetRange("C2").SetValue(200);
oWorksheet.GetRange("A3").SetValue("Andrew");
oWorksheet.GetRange("B3").SetValue(21);
oWorksheet.GetRange("C3").SetValue(300);
oWorksheet.GetRange("E1").SetValue("Sales");
oWorksheet.GetRange("E2").SetValue(">200");
var oRange1 = oWorksheet.GetRange("A1:C3");
var oRange2 = oWorksheet.GetRange("E1:E2");
oWorksheet.GetRange("E4").SetValue(oFunction.DAVERAGE(oRange1, "Sales", oRange2));

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).