Commit f4abb0d5 authored by GoshaZotov's avatar GoshaZotov

add RANK.AVG formula

parent 33219f8c
......@@ -62,7 +62,7 @@
cFORECAST_ETS_CONFINT, cFORECAST_ETS_SEASONALITY, cFORECAST_ETS_STAT, cFORECAST_LINEAR,
cHYPGEOM_DIST, cMODE_MULT, cMODE_SNGL,
cNEGBINOM_DIST, cNORM_DIST, cNORM_INV, cNORM_S_DIST, cNORM_S_INV, cPERCENTILE_EXC, cPERCENTILE_INC,
cPERCENTRANK_EXC, cPERCENTRANK_INC, cPERMUTATIONA, cPHI, cPOISSON_DIST, cQUARTILE_EXC, cQUARTILE_INC, cRANK_AVG,
cPERCENTRANK_EXC, cPERCENTRANK_INC, cPERMUTATIONA, cPHI, cPOISSON_DIST, cQUARTILE_EXC, cQUARTILE_INC,
cSKEW_P, cSTDEV_P, cSTDEV_S, cT_TEST, cVAR_P,
cVAR_S, cWEIBULL_DIST, cZ_TEST);
cFormulaFunctionGroup['Financial'] = cFormulaFunctionGroup['Financial'] || [];
......@@ -80,7 +80,7 @@
cCONFIDENCE_NORM, cCONFIDENCE_T, cCOVARIANCE_P, cCOVARIANCE_S, cF_TEST, cFORECAST_ETS, cFORECAST_ETS_CONFINT,
cFORECAST_ETS_SEASONALITY, cFORECAST_ETS_STAT, cFORECAST_LINEAR, cHYPGEOM_DIST, cMODE_MULT, cMODE_SNGL,
cNEGBINOM_DIST, cNORM_DIST, cNORM_INV, cNORM_S_DIST, cNORM_S_INV, cPERCENTILE_EXC, cPERCENTILE_INC,
cPERCENTRANK_EXC, cPERCENTRANK_INC, cPERMUTATIONA, cPHI, cPOISSON_DIST, cQUARTILE_EXC, cQUARTILE_INC, cRANK_AVG,
cPERCENTRANK_EXC, cPERCENTRANK_INC, cPERMUTATIONA, cPHI, cPOISSON_DIST, cQUARTILE_EXC, cQUARTILE_INC,
cSKEW_P, cSTDEV_P, cSTDEV_S, cT_TEST, cVAR_P, cVAR_S, cWEIBULL_DIST, cZ_TEST, cPDURATION, cRRI,
cAGGREGATE, cMUNIT, cFORMULATEXT, cISFORMULA, cSHEET, cSHEETS);
......@@ -672,18 +672,6 @@
cQUERYSTRING.prototype = Object.create(cBaseFunction.prototype);
cQUERYSTRING.prototype.constructor = cQUERYSTRING;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cRANK_AVG() {
cBaseFunction.call(this, "RANK.AVG");
this.isXLFN = true;
}
cRANK_AVG.prototype = Object.create(cBaseFunction.prototype);
cRANK_AVG.prototype.constructor = cRANK_AVG;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
......@@ -68,7 +68,7 @@
cGEOMEAN, cGROWTH, cHARMEAN, cHYPGEOMDIST, cINTERCEPT, cKURT, cLARGE, cLINEST, cLOGEST, cLOGINV, cLOGNORM_DIST,
cLOGNORM_INV, cLOGNORMDIST, cMAX, cMAXA, cMEDIAN, cMIN, cMINA, cMODE, cNEGBINOMDIST, cNORMDIST, cNORMINV,
cNORMSDIST, cNORMSINV, cPEARSON, cPERCENTILE, cPERCENTRANK, cPERMUT, cPOISSON, cPROB, cQUARTILE, cRANK,
cRANK_EQ, cRSQ, cSKEW, cSLOPE, cSMALL, cSTANDARDIZE, cSTDEV, cSTDEVA, cSTDEVP, cSTDEVPA, cSTEYX, cTDIST,
cRANK_AVG, cRANK_EQ, cRSQ, cSKEW, cSLOPE, cSMALL, cSTANDARDIZE, cSTDEV, cSTDEVA, cSTDEVP, cSTDEVPA, cSTEYX, cTDIST,
cT_DIST, cT_DIST_2T, cT_DIST_RT, cT_INV, cT_INV_2T, cTINV, cTREND, cTRIMMEAN, cTTEST, cVAR, cVARA, cVARP,
cVARPA, cWEIBULL, cZTEST);
......@@ -5597,6 +5597,54 @@
return this.value = this._findArrayInNumberArguments(oArguments, calcTDist);
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cRANK_AVG() {
cBaseFunction.call(this, "RANK.AVG");
}
cRANK_AVG.prototype = Object.create(cBaseFunction.prototype);
cRANK_AVG.prototype.constructor = cRANK_AVG;
cRANK_AVG.prototype.argumentsMin = 2;
cRANK_AVG.prototype.argumentsMax = 3;
cRANK_AVG.prototype.isXLFN = true;
cRANK_AVG.prototype.Calculate = function (arg) {
var oArguments = this._prepareArguments(arg, arguments[1], true, [null, cElementType.array]);
var argClone = oArguments.args;
//1 argument - array
argClone[0] = argClone[0].tocNumber();
argClone[2] = undefined !== argClone[2] ? argClone[2].tocNumber() : new cNumber(0);
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
}
var calcTDist = function(argArray){
var number = argArray[0];
var ref = argArray[1];
var order = argArray[2];
if(!ref.length){
return new cError(cErrorType.wrong_value_type);
}
var changedRef = [];
for(var i = 0; i < ref.length; i++){
if(cElementType.number === ref[i].type){
changedRef.push(ref[i]);
}
}
var res = rank(number, changedRef, order, true);
return null !== res && !isNaN(res) ? new cNumber(res) : new cError(cErrorType.wrong_value_type);
};
return this.value = this._findArrayInNumberArguments(oArguments, calcTDist);
};
/**
* @constructor
* @extends {cRANK}
......@@ -5608,6 +5656,7 @@
cRANK_EQ.prototype = Object.create(cRANK.prototype);
cRANK_EQ.prototype.constructor = cRANK_EQ;
cRANK_EQ.prototype.isXLFN = true;
/**
* @constructor
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment