Percentage in child table based on Doctype grand total

I have a child table (CONTEOS) with two columns: “n_granos” and “porcentaje” in a Doctype call Mieles Pampero. In the Doctype I have a field call “total”. I have done the script for “total” that sum “n_granos”. I want to calculate the “porcentaje” / percentage in each row like: n_granos/total. Can somebody help me? Thanks!!