Skip to content

Instantly share code, notes, and snippets.

@dhilipsiva
Created May 30, 2016 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhilipsiva/a06086ca80ad9f54fa0afd2e0b57b8fc to your computer and use it in GitHub Desktop.
Save dhilipsiva/a06086ca80ad9f54fa0afd2e0b57b8fc to your computer and use it in GitHub Desktop.
This is Google Sheet custom scripts to get total stats.
/*
This is Google Sheet custom scripts to get total stats.
*/
function BFCOUNT(range) {
var ss = SpreadsheetApp.getActive();
var numRows = range.length;
var items = {};
for (var key in range) {
if (range.hasOwnProperty(key)) {
item = range[key];
var oldVal = items[item]
if( oldVal === undefined){
oldVal = 0;
}
items[item] = oldVal + 1;
}
}
var strItem = "";
for(var item in items){
count = items[item];
strItem += item + ": " + count + "\n";
}
return strItem;
}
function LUNCHCOUNT(range) {
var ss = SpreadsheetApp.getActive();
var numRows = range.length;
var count = 0;
for (var key in range) {
if (range.hasOwnProperty(key)) {
item = range[key];
if(item == "Yes"){
count+=1;
}
}
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment