Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running balances or totals

Status
Not open for further replies.

Danster

Technical User
May 14, 2003
148
AU
Gday all,
I have an account opening balance in my group header (grouped on field account number).

In my details section I have debit and credit transactions -basically +ve and -ve amounts.
All I want is a running balance but I've tried using a running total field and can't get it to work.
Suggestions anyone?

regards

Danster
 
You should explain how this opening balance is acquired.

Is it a summary field?

Running Totals might do this, but I doubt it will work because it's probably a sum() field which provides the opening balance, which means it isn't available to the RT until afterwards.

And when you say something doesn't work, provide specifics. Are you getting an error? Does it provide a wrong answer?

You're probaby best served to describe version of Crystal, database, provide example data, and expected output.

If this is a calculation opening balance is derived for the group, then you'll have to create a formula to provide the balance, as in:

Group Header section:
numbervar OpenBal := sum({table.ve,{table.acctnum});
OpenBal

Details section:
numbervar OpenBal;
OpenBal := OpenBal+{table.ve};
OpenBal // Current value

Group Footer section:
numbervar OpenBal;
OpenBal // End balance for that section which will be zero.

G'day,

-k
 
The opening balance is a numeric field I am reading from my database Accounts.OpeningBalance. How it gets there is beyond the scope of my question, but lets say it is calced elsewhere in the app and an opening balance ends up in this field. It is in a account header table, whereas the transactions are in a Transactions table.

My running total field doesn't work not due to any error, but because I'm unsure of the formula needed.
If I have a formula field which says
{opening balance}+{transaction amount} then the formula is obviously incorrect. If it says Sum({transaction amount},acct number)+ {opening balance} then that is incorrect also because I don't want the opening balance added on each detail, just the first time.

I haven't tried your answer yet, but reading it through, I think it might just work. Stand by!

cheers
Danster
 
Sorry Synapsevampire,
the formula suggested doesn't work. Each line in details is not cumulative - it reads the OpenBal from the group header each time.
E.g. It is showing thus...
Group Header Section
Acct Number ABC123 Opening Balance $1000

Details
Transaction $100 Bal: $1100
Transaction $250 Bal: $1250
Transaction $-50 Bal: $950


It should show the details thus...
Transaction $100 Bal: $1100
Transaction $250 Bal: $1350
Transaction $-50 Bal: $1300

cheers

Danster


 
The running total should be based on the new values only as in:

Group Header section:
numbervar AccumTrans := 0;

Details section:
numbervar AccumTrans := AccumTrans + {table.ve};
AccumTrans + {table.openbal};

Group Footer section:
numbervar AccumTrans;
AccumTrans + {table.openbal};

Or you could use the running total editor instead to create {#ve}--select {table.ve}, sum, evaluate for every record, reset on change of group. Then create a formula:

{#ve}+{table.openbal}

And place this in both details and group footer sections.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top