RANK

function RANK(arg1: number = null, arg2: number[] | ApiRange = null, arg3: boolean = null): number

Description

Returns the rank of a number in a list of numbers: its size relative to other values in the list.

Parameters

arg1numberdefault: null

The number for which the rank will be returned.

arg2number[] | ApiRangedefault: null

An array of numbers or a reference to a list of numbers. Nonnumeric values are ignored.

arg3booleandefault: null

The numeric value that specifyes how to order the numbers. If it is 0 or omitted, the rank in the list will be sorted in descending order. Any other numeric value means that the rank in the list will be sorted in ascending order.

Returns

number

Try It


const oWorksheet = Api.GetActiveSheet();

var valueArr = [7,6,5,5];

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

//method params
var number = oWorksheet.GetRange("A3");
var range = oWorksheet.GetRange("A1:A4");
var order = 0;

var oFunction = Api.GetWorksheetFunction();
var ans = oFunction.RANK(number,range,order); 

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