Hi guys, if you need to get the sum or average of a grid column, you can use

**Aggregate functions**, to get more information about them click on the following link:

http://wiki.processmaker.com/index.php/ ... _functions
You can also use javascript to loop through the rows in the grid and get the value of the field you want to work with.

A quick sample

Code: Select all```
function sumGridColumn(gridName, fieldName) {
/* Get the number of rows in the grid */
var rowCount = Number_Rows_Grid(gridName, fieldName);
var total = 0;
for (var i = 1;i <= rowCount;i++) {
/* Get the row's field value */
total += parseFloat(getGridField(gridName, i, fieldName).value);
}
return total;
}
/* Set the value of the field that'll hold the sum */
getField('targetTotalField').value = sumGridColumn('yourGridName', 'fieldToSum');
```

I chose to use a function in my javascript code because I might need to calculate other columns on demand, this is just a basic example, you can modify the code to do any necessary validation.

**@HSchlierkamp**
Your case is a bit different since you want to sum hours, I've checked the function you're using and found that some variables don't match, even after fixing that issue you won't get the results you want because of time calculation, I would recommend you to work with minutes, so you'd need to create two functions, one to convert your hh:mm formatted time to minutes, and one to convert minutes to hh:mm formatted time, once you have these functions, you can loop through the grid rows, convert each field value to minutes, sum the total of minutes and at the end convert them to hh:mm formatted time to use that value in the Total Hours field.

.