Skip to content

Instantly share code, notes, and snippets.

@cherihung
Last active December 16, 2015 19:29
Show Gist options
  • Save cherihung/5485257 to your computer and use it in GitHub Desktop.
Save cherihung/5485257 to your computer and use it in GitHub Desktop.
Google app script to use with google spreadsheets. Function calculating the occurance/count in a doc based on 3 optional parameters.
// CalSum Function with Three Optional Parameters
function calSumC(dR1,dP1,dR2,dP2,dR3,dP3) {
var count=dR1.length;
var t1= new RegExp(dP1);
var t2= new RegExp(dP2);
var t3= new RegExp(dP3);
var s=0;
for (i=0;i<count;++i){
var v1=dR1[i][0];
var v2=dR2[i][0];
var v3=dR3[i][0];
//match one of these parameters
if(t1.test(v1) || t2.test(v2) || t3.test(v3)) {
s=s+1;
} //end 1
}
return(s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment