TRY NEW VERSION

VARPA

VARPA(args) → { number }

Calculates variance based on the entire population, including logical values and text. Text and the false logical value have the value 0; the true logical value has the value 1.

Parameters:

Name Type Description
args number | string | boolean | ApiRange | Array.<number>

Up to 255 values for which the variance will be calculated. The first argument is required, subsequent arguments are optional.

Returns:

Type
number

Example

Copy code
builder.CreateFile("xlsx");

var oWorksheet = Api.GetActiveSheet();

// Data array
var data = [
    [1, 0, 0, false],
    ["text", 1, 0, 0],
    [2, 3, true, 7],
    [6, 8, 10, 12]
];

// Place the data in cells A1:D4
for (var i = 0; i < data.length; i++) {
    for (var j = 0; j < data[i].length; j++) {
        oWorksheet.GetRangeByNumber(i, j).SetValue(data[i][j]);
    }
}

// Calculate the VARPA of the range A1:D4 and place the result in cell D5
var oFunction = Api.GetWorksheetFunction();
var varpaResult = oFunction.VARPA(oWorksheet.GetRange("A1:D4"));
oWorksheet.GetRange("D5").SetValue(varpaResult);


builder.SaveFile("xlsx", "VARPA.xlsx");
builder.CloseFile();

Resulting document