I want to get sums of numeric values for each separate column in the range. What I do wrong?
function countNutrients(){
var sh = SpreadsheetApp.getActiveSheet();
var lastcol = sh.getLastColumn(); //Get last column
var lastcolval = sh.getRange(1, 1, 1, lastcol).getValues();
var lastrowval = sh.getRange("C1:C").getValues(); //Trick to get last row
var lastrow = lastrowval.filter(String).length; //
var sumvalues = sh.getRange(2, 14, lastrow, lastcol).getValues();
(typeof sumvalues === 'number' ? "" : sumvalues);
Logger.log(sumvalues);
for (var j = 13; j < lastcolval.length ; j++) {
var sumcolumnval = sh.getRange(2, [j], lastrow);
var sum = 0;
for (var i in sumcolumnval[0]) {
var sum = sumvalues[0][i] + sum;
}
return sum
Logger.log(sum);
}
return sumcolumnval
}
Columns on the screenshot and 65 more
CSV example