Support

Account

Home Forums Add-ons Repeater Field Sum Values of Sub Fields in Nested Repeater Reply To: Sum Values of Sub Fields in Nested Repeater

  • Here is the code I came up with, just in case anyone else finds it useful:

    
    <?php 
    	$tasks = get_sub_field('project_task'); $totaltasks = count($tasks);
    	$totaltaskpercentage = 0;
    		while ( have_rows('project_task') ) : the_row(); 
    			$totaltaskpercentage += intval( get_sub_field('project_task_percentage'));
    		endwhile; 
    	$grouptaskpercentage = $totaltaskpercentage / $totaltasks;
    	echo round($grouptaskpercentage);
    	?>