### Title

Calculation on a running total

### Post

I'm doing a fairly basic program that has a few calculations. I have half of it down pat but need some help on the rest.

Here's what I have: We are looking at video of a rat. When the rat enters sideA, and when it leaves sideA, we write those times down (Example 0:05:15 to 0:08:10). These are organized by day, but there are multiple videos per day.

I have table 1 set up for basic information (date, time etc). There is a portal to table 2. This includes 2 columns for "Time in" and "Time out". Next to that I have a column that subtracts the two to give us the Time Spent in SideA. This all works great.

In another portal to table 2 I have 2 columns. Video ID Number and Video Length. We're all good there.

Here is where I hit my snags. My final portal to table 2 has 2 columns.

Total Time in SideA, with the calculation Sum ( Time Spent In SideA)

Percentage of Time in SideA, with the calculation Sum ( Time Spent In Side Instance ) / Total Video Time Length

I also have a field that is not showing: Total Video Time, with the calculation Sum ( Video Time Length )

My problem is in the last portal with 2 columns, I actually want just one box with a running total of the Total Video time, Time in SideA and Percentage of Time in SideA. What I'm getting is each time I enter data in the other entry places, this column makes a new line too (so it shows multiple field entries). How do I fix this so it's just one box with my final calculations?

I tried changing the portal for those 2 columns to 1 line, but it doesn't update the information when I enter new data in the first 2 portals. What am I doing wrong?

Here is a screen shot of what it looks like. The bottom right columns are the ones I'm trying to fix (the numbers/times are random ones I typed to see if it worked).

I see two ways to do what you want, but a few details bother me and I'd like clarification on those points first to avoid confusion when you try to implement one of these suggested solutions:

Sum ( Time Spent In SideA)

Sum ( Time Spent In Side Instance ) / Total Video Time Length

Sum ( Video Time Length )

Are these

exactlywhat you are using here?Sum has two basic formats:

Sum ( field1 ; field2 ; field3 ) which is the same as just using field1 + field2 + field3

Sum ( relatedTable::Field1 ) which computes the sum of Field1 from all related records in the specified relatedTable's table occurrence.

Sum ( field1 ) will produce the same result as just entering Field1 in the specify calculation dialog.

And what kind of field is Total Video Time Length? A summary field?

Your two possible solutions:

With option 2, you may also need a triggered sript to refresh your window each time you save or exit one of the Time fields in the first total to make sure that these totals update promptly.