Filtered Child table Row count

Hello Experts, Im newbie on ERPNext and I move my company from Zoho to ERPNext. I used to program zoho, and I’m learning ERPNext using this forum. But I have an scenario that I can´t solve so far and maybe you can point me to the right direction:
Doc1 is a custom Doctype with 3 data fields: Choice1 Choice2 and Choice3, and a ChildTable named table. The child table has a field called selector with 3 choices (A,B,C). What Im trying to achieve using custom script is:
Read the rows from table, count how many rows are with field Selector=A and write the value in Choice1, the same for Selector=B, and Selector=C. Can you point me to some resources please?

Maybe my question was too easy to deserve a reply :slight_smile: … Today I found a solution but is not fancy at all. I post it because maybe it can be helpful to somebody:

var tipo1=0,tipo2=0,tipo3=0;Por_1=0,Por_2=0,Por_3=0;
//tipo1 is a counter
//check table lenght
var num_reg=cur_frm.doc.table.length;
//Count the number of registers with Selector field in A,B orC

for (i = 0; i < num_reg; i++) {
else if(cur_frm.doc.table[i].selector==“B”){tipo2=tipo2+1;}
else if(cur_frm.doc.table[i].selector==“C”){tipo3=tipo3+1;}

//Calculate row percentage for each option
//Write results in the custom fields