<?php $count = count(get_field('ss_results')); $tasks = get_sub_field('ss_results'); $totaltasks = count($tasks); $totaltaskpercentage = 0; while ( have_rows('ss_results') ) : the_row(); $totaltaskpercentage += intval( get_sub_field('test_score')); endwhile; $grouptaskpercentage = $totaltaskpercentage / $totaltasks; $final_result = round($grouptaskpercentage)/$count; ?>