SMALL

function SMALL(arg1: number[] | ApiRange = null, arg2: number = null): number

Description

Returns the k-th smallest value in a data set. For example, the fifth smallest number.

Parameters

arg1number[] | ApiRangedefault: null

An array or range of numerical data for which the k-th smallest value will be determined.

arg2numberdefault: null

The position (from the smallest) in the array or range of the value to return.

Returns

number

Try It


const oWorksheet = Api.GetActiveSheet();

var valueArr = [1, 0, 0, 0, 0, 1, 0, 0, 2, 3, 4, 5, 6, 8, 10, 12];

// Place the numbers in cells
for (var i = 0; i < valueArr.length; i++) {
 oWorksheet.GetRange("A" + (i + 1)).SetValue(valueArr[i]);
}

// method params
var range = oWorksheet.GetRange("A1:A16");
var position = 8;

var oFunction = Api.GetWorksheetFunction();
var ans = oFunction.SMALL(range, position);

oWorksheet.GetRange("C1").SetValue(ans);

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).