1 Reply Latest reply on Apr 21, 2015 7:10 AM by philmodjunk

# Summed value of values in current record and previous record

### Title

Summed value of values in current record and previous record

### Post

Couldn't find anything on the internet on this, but perhaps i'm not using the right keywords. An example of what i want:

Record 1: value a = 10, value b = 5, value c = a - b (so value c = 5)
Record 2: value a = 3, value b = 2, value c = value c from record 1 + a - b (so value c here is 5 + 3 - 2 = 6)

The starting value of value c = 0, and then for each subsequent record it need to take into account the previous record's value. Much like in excel is done often te keep a 'saldo' of something, for example the cash machine in a shop. When in this case the starting value is zero, then on the first day (record 1) 10 euros is sold and 5 euros is spent, so after day one, there is 5 euros left. Then on the second day 3 euros is sold and 2 euros is spent, so the accumulated value is now 6.

Any help is appreciated.

• ###### 1. Re: Summed value of values in current record and previous record

Let's call field a "debit", field b "credit" and field c, "cBal".

Define cBal as a calculation field with a number result type and this expression: Debit - Credit.

Now define a summary field: sBalance as the running total of cBal

In a list or table view, you can get a view of your data where each record is a row with these fields. The cBal field need not be present on the layout if you don't need it.

This is a standard "bookkeeping ledger" type solution (hence the field names that I used here and in this demo file that I created some time ago: https://dl.dropboxusercontent.com/u/78737945/AccountingLedger.fmp12