### How to made statistics (percentage table) ?

On input, we have a survey (web) as below:
Grp_name;Nb_Members ;Agree ;
Group1 ; 8 ;No ;
Group2 ; 2 ;Yes ;
Group3 ; 6 ;Yes ;
Group4 ; 4 ;Yes ;

On output, we would like to return the total and the percentage, by group and by members, for each answers.
________ ;Yes ;No ;
Nb_Groups ;3(75%) ;1(25%) ;
Nb_Members ;12(60%);8(40%) ;

Details:
On each test, the number of groups or members can change, even the answers.

I would like to know if there is a function which can help us ?
Or should I create a Javascript myself ?

So, I extracted the variables as below:
Grp_name=[Group1,Group2,Group3,Group4]
Nb_Members=[8,2,6,4]
Agree=[No,Yes,Yes,Yes]

Then we have to build the new variable like this:
URL={"survey":{"yes":{"Nb_Groups":3,"percentage1":75,"Nb_Members":12,"percentage2":60},
"no":{"Nb_Groups":1,"percentage1":25,"Nb_Members":8,"percentage2":40}}}

Finally, I created a script as below. I hope it will help someone one day.

var text ="";
var i = 1;
var temp = 0;
var agree = "";
var TotalGrps = 0;
var TotalMembers = 0;
var nb_MembersYes = 0, nb_MembersNo = 0;

TotalGrps = context.variableManager.getValue("Grp_name_matchNr");
text += "\"survey\":[";

while ( i <= TotalGrps ) {
temp = context.variableManager.getValue("Nb_Members_"+i);
agree = context.variableManager.getValue("Agree_"+i);

if (agree == "yes") {
nb_MembersYes += parseInt(temp);
} else {
nb_MembersNo += parseInt(temp);
}
TotalMembers += parseInt(temp);
i++;
}