I have a Views table of my Webform Submissions, with the below fields:

1= Item (Webform submission: Value)
2= Date (Webform submission: Value)
3= Time In (Webform submission: Value)
4= Time Out (Webform submission: Value)
5= Duration (Global:php) ( This field contains some php codes to calculate the number of hours between Time In and Time Out)

And I have an exposed filter of (Webform submission:data field) which filters the data by the Date field.

Then I needed to add a Percentage field, which can calculate the percentage of the total Sum of the Duration field for each row.
For Example:
Item Duration Percentage
A 2.5 20.8%
B 3 25%
A 2 16.67%
C 4.5 37.5%
-----------------------------------
Total 12 100%

For the Percentage field I used Global:php field with below code in the output:

/*calling the view to get all the values, 
 * this is because you have a pager in your view.
 */
//setting the view name  
$view = views_get_view('form');
//executing the view
$view->execute();
//sum of all rows
$sum = 0;
//iterating over the view result
foreach($view->result as $object) {
  //calculating the total	
  $sum += $object->views_php_6;   	
}	
//calculating the percent value for each row
$percent = number_format($row->php * 100 / $sum, 2);
print $percent;

Now the problem is that values of this field doesn't change after filtering, It always shows same values!

I've been stuck with this issue for several weeks!
Any helps is appreciated,

Thanks

Comments

maryam.naji68@gmail.com’s picture

Issue summary: View changes