Commit b9c1c1a1 authored by GoshaZotov's avatar GoshaZotov

add function for DSUM formula

parent 5baa9371
......@@ -603,6 +603,36 @@
cDSUM.prototype = Object.create(cBaseFunction.prototype);
cDSUM.prototype.constructor = cDSUM;
cDSUM.prototype.argumentsMin = 3;
cDSUM.prototype.argumentsMax = 3;
cDSUM.prototype.Calculate = function (arg) {
var oArguments = this._prepareArguments(arg, arguments[1], true, [cElementType.array, null, cElementType.array]);
var argClone = oArguments.args;
argClone[1] = argClone[1].tocString();
var argError;
if (argError = this._checkErrorArg(argClone)) {
return this.value = argError;
}
var resArr = getNeedValuesFromDataBase(argClone[0], argClone[1], argClone[2]);
if(cElementType.error === resArr.type){
return resArr;
}
var summ = 0;
for(var i = 0; i < resArr.length; i++){
var val = parseFloat(resArr[i]);
if(!isNaN(val)){
summ += val;
}
}
var res = new cNumber(summ);
return this.value = cElementType.error === res.type ? new cNumber(0) : res;
};
/**
* @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