6 Replies Latest reply on Aug 14, 2011 10:15 AM by chlowden

# How to have a running sum of previous fields?

### Title

How to have a running sum of previous fields?

### Post

Hello

I am a total newby on filemaker. i have a table that is designed to a debits and credits field in a list. I use the summary function to addition all of the credits and another to addition for the debits. I have a 3rd field summary field that gives me the total difference of both fields. Obviously, this running total result is repeated in each table entry.

I am struggling to have a running total where each entry progressively adds or subtracts from the sum of all the previous entries. This would give me a result like a bank statement, telling me what the consequences of each entry are on the sum up until that point.

I am not sure how clear this is, but in excel it is as simple subtracting or adding from the sum cell of a column.

Many thanks for any ideas

• ###### 1. Re: How to have a running sum of previous fields?

It would be easier if you used one field for debit/credit (debit plus amount; credit minus amount).

Delete your last field sTotalGlobal and add field (type calculation) called cLineDiff (result is number) with MontantReceites - MontantDepense, selecting your regular fields and not the summary fields.  Now create a summary field sRunning (which is Total of cLineDiff and at bottom, checkbox 'running.'

If you used only one field, you wouldn't need that calculation at all because the summary would reference only one field (your amount).

• ###### 2. Re: How to have a running sum of previous fields?

Many thanks for this perfectly simple solution.

As a development, would it be possible to associate the running field to a date field? For the moment, the figures change when the order changes. Similar logic to that of a bank statement.

Many thanks again

• ###### 3. Re: How to have a running sum of previous fields?

"would it be possible to associate the running field to a date field?"

I'm not sure what you mean.  Running balance changes based upon whether values change in the amount field(s).  Can you explain more what you want?

• ###### 4. Re: How to have a running sum of previous fields?
Sorry for being unclear. As I understand it, the result is running as per the order of the entries. If you change the order of the entries, the results are different even if the sum remains the same. So I was wondering if the running calculation could be based on a manually entered date rather than the presented order?
• ###### 5. Re: How to have a running sum of previous fields?

Sort by that date (within the script) instead of the creation order, right before viewing the report.  You will need to Show All Records because amounts are based upon records in the found set.

• ###### 6. Re: How to have a running sum of previous fields?
Well that was embarassing. I was ready for some complex calculation. Many thanks for another perfectly simple solution.