HTML view sum example

HTML view sum example

Can someone provide me an example of how to calculate the total absolute values of a field in an html view?

For example:
FormA
One entry is this:
Field1=10
Field2=5
The second entry is this:
Field1=5
Field2=5
The third entry is this:
Field1=2
Field2=1

HTMLView
Field1Total=17 (10+5+2)
Field2Total=11 (5+5+1)

I'm assuming this can be done with the "for each" clause, however I'm stuck on figuring out how to calculate the sum in an html view.