# Calculate average from child table

I want calculate average of work completed. This child table is read only.
i want to add all ‘Work Completed’ score and fine average and display in ‘Total Work Plan Complete(100%)’ before save.

i used below code:

cur_frm.cscript.total_work_plan = function(doc,cdt,cdn){
var total3 = 0;
var row_length = cur_frm.doc.plan_template.length || 0;
\$.each(cur_frm.doc.plan_template || [], function(i, row){
total3 += row.work_completed/row_length;
});
cur_frm.set_value(“total_work_plan”, total3);
//doc.total_work_plan = flt(total3);
refresh_field(‘total_work_plan’);

``````}
``````

sorry for repeated question
{"ft_lang_label":"__label__en","ft_lang_prob":0.66782004,"math_prob":0.97104007,"size":591,"snap":"2022-40-2023-06","text_gpt3_token_len":148,"char_repetition_ratio":0.14821124,"word_repetition_ratio":0.0,"special_character_ratio":0.2825719,"punctuation_ratio":0.25233644,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97954863,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-02-05T07:59:06Z\",\"WARC-Record-ID\":\"<urn:uuid:95caf21f-7e04-46ba-be17-50bd084bb366>\",\"Content-Length\":\"13276\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:af7af5f8-65cd-4dd3-ae8a-55eeb7711495>\",\"WARC-Concurrent-To\":\"<urn:uuid:3c0b4993-bdff-4907-b9e8-b4a26cd6f48f>\",\"WARC-IP-Address\":\"64.227.130.54\",\"WARC-Target-URI\":\"https://discuss.frappe.io/t/calculate-average-from-child-table/45693\",\"WARC-Payload-Digest\":\"sha1:VR25FCA7SQZ77TP42CI2BXLKI5FQGXIK\",\"WARC-Block-Digest\":\"sha1:U4U7FCLWYG7ZGL4D2NIU6HJPGE2AQYDK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-06/CC-MAIN-2023-06_segments_1674764500250.51_warc_CC-MAIN-20230205063441-20230205093441-00277.warc.gz\"}"}