Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Running Total

How do calculate a running total (such as a bank balance) in a table box?

I would like to calculate the running total for the following bank file

No     Detail               Amount

1         Start balance     10

2          Deposited           5

3          Withdrawn         -2

to get the following Table Box:

No     Detail               Amount     Balance

1         Start balance     10          10

2          Deposited           5          15   

3          Withdrawn         -2          13

If have tried to use the following

SELECT


    `BankNo` As 'No',

     `BankDetail` As 'Detail',

    `BankAmount` As 'Amount',

    `Amount` + Previous(`Amount`) As 'Balance'

FROM `db`.`bank` AS `bank`

but I get the error message Function Previous does not exist?

15 Replies
Not applicable
Author

Thanks a lot. I eventually managed it

Not applicable
Author

Thanks a lot. I eventually managed it

Not applicable
Author

Thanks a lot. I eventually managed it

giakoum
Partner - Master II
Partner - Master II

jannielouw, please mark as answered so that we close this discussion.

Thnak you.

robert99
Specialist III
Specialist III

There is an example in the QV manual that I have used

Under peek

load

A,

B,

numsum(B,PEEK('BSUM')) AS BSUM ...

creates an accumulation of B in BSUM

This might also work

Not applicable
Author

Thanks. I did get the previous example going