SHARE
TWEET

Untitled

a guest Jun 27th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function filteredSum(){
  2.  
  3.  var ss = SpreadsheetApp.getActiveSpreadsheet();
  4.  var tsheet = ss.getSheetByName("Sheet1");
  5.  
  6.  var originalData = tsheet.getRange(10, 1, tsheet.getLastRow()-1, 2).getValues();
  7.  var mindate = tsheet.getRange("C8").getValue();//starting date
  8.  var maxdate = tsheet.getRange("D8").getValue();//end date
  9.  
  10.   var data = originalData.filter(function(item){return item[0] >= mindate && item[0] <= maxdate});
  11.  
  12.  
  13.   Logger.log(data);
  14. //here i got the array of arrays. and i'm stuck. how to get the sum of numbers
  15.  
  16.  }
  17.      
  18. var sum = data.reduce(function(a,b){
  19.   return a + b[1];
  20. }, 0);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top