Link to home
Start Free TrialLog in
Avatar of Mark01
Mark01Flag for United States of America

asked on

Crystal Reports Formula

I'm working on a formula to prepare a financial statement that is very similar to a brokerage statement. The brokerage receipts for a specified period of time will be added to the beginning account balance for the same time period to come up with a subtotal. I'm using an Access 2003 database. The specified time period must be coded into the formula. Any assistance would be greatly appreciated.

Here are more details about the current version of the report.

Groups:
Brokerage Account (grouped on the Account number)
Brokerage Receipt Description (grouped on the brkReceiptDescr field)

Formulas

Receipts Sum 1:
Sum({tblBrokgRecpts.brkgReceiptAmt},{tblBrokerageAccounts.AccountNumber})


Receipts And Beg Bal:
{@Receipts Sum 1} + {@Beginning Balance}

Beginning Balance:
{tblBrkgAcctDate_BrkgAcct_Link.brkbdBalnce}


The babdDate field from the tblBrkgkAcctBalDates table has to used in the formula. For example, in the sample layout below, the date, 1-1-2011, is in the tblBrkgkAcctBalDates table. The beginning balance of $1,000 is in the tblBrkgAcctDate_BrkgAcct_Link table.


Here’s a sample layout:
Account #1
Beginning balance, 1-1-2011, $1,000
Dividend income - 1-3-11 $500
Dividend income - 1-7-11 $500
Total Dividend income $1,000
Ending balance, 1-31-2011, $2,000


Tables

There are other fields so the tables can JOIN appropriately.

tblBrkgkAcctBalDates
babdDate :DateTime (field)



tblBrokerageAccounts
AccountNumber :Text (field)


tblBrokgRecpts
brkgReceiptDate :DateTime (field)
brkgReceiptAmt :Currency = 0 (field)


tblBrokgRecptDescr
brkReceiptDescr :Text (field)

NOTE: Examples of data in brkReceiptDescr are "Dividend Income" and "Interest Income."

tblBrkgAcctDate_BrkgAcct_Link
BrokerageAccountID(Long) (field)
BrkgAcctBalDateID(Long) (field)
brkbdBalnce :Currency (field)
Avatar of Mike McCracken
Mike McCracken

What is your issue?

mlmcc
Avatar of Mark01

ASKER

User generated imageHi mlmcc,

I don't know how to write the formula(s). This image may help.
Do you get 1 record per account or several?

If it is several you probably don't need formulas just put the fields in the detail section where you want them to appear.

You probably need to group on Account Number to ensure all records for an account stay together

mlmcc
Looking at the formulas in your first post:

 The CR summary functions, like Sum, always return the summary for the entire group/report, not for individual records or anything like that.  So, Sum ({tblBrokgRecpts.brkgReceiptAmt},{tblBrokerageAccounts.AccountNumber}) will always give you the total brkgReceiptAmt for the current AccountNumber.  If you put that in the detail section, you'll get the same figure on every line.

 {@Receipts And Beg Bal} should give you the total for the records in the current account, plus the beginning balance, so that should give you the ending balance.  You would probably want that in the group footer, or header.

 If you want a running total with the total brkgReceiptAmt up to the current record, plus the beginning balance, I'd probably create a running total for brkgReceiptAmt (reset on change of AccountNumber group), and then create a formula like {@Receipts And Beg Bal} that added the running total and brkbdBalnce together.


 FWIW, if {@Beginning Balance} is just the brkbdBalnce field, you don't need to use a formula for that.  I would just use the field.  But if you'd rather put it in a formula, that's fine.

 James
Avatar of Mark01

ASKER

User generated imageUser generated imagemlmcc and James0628:

Both of you are way ahead of me. The attached "Current Report" image shows the basic problem I'm having which is that I don't know how to code in the date of the beginning balance field in a formula. A balance appears on the current version of the report, but I don't know what date it corresponds to. The second image ("CR table links") shows the report designer table links. Both images are in jpg and pdf for your convenience.
All-Pdf.pdf
Well, of course, that depends on your data.  If you've got a beginning balance field, there is presumably some kind of date or fiscal period or something that goes with it, so it's the beg balance as of that date/period.

 If you're running the report with a starting date, will your data include a beg balance for that date, or do you need to calculate that beg balance?  If you need to calculate the beginning balance, that will probably mean reading some "extra" data somewhere (the transactions between the beg balance that's on file and your actual starting date).

 Simplest case - You will have a beginning balance for whatever starting date you choose (eg. the first of a month), so add a test to the record selection so that the report only includes the beg balances for the correct month.  Have the record selection only include the transactions for the desired time period, starting on the first of that month.  Add those transactions to that beg balance.

 James
Avatar of Mark01

ASKER

User generated imageUser generated imageThe beginning balance and corresponding date functions properly. The only problem I have is totaling the various types of brokerage receipts for each month. Is Running Total the best way to deal with this? If the answer is yes, how do I write the formula? The attached image shows the type of totals that I need.
All-Pdf.pdf
SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark01

ASKER

I solved the problem by creating a new Brokerage Receipt Date group (grouped on the brkgReceiptDate).

I do not want any account to appear twice on the report. In the "desired version" examples, I showed the first account twice, at the beginning and again at the end to show both the sum and running total for the brokerage account income. You can disregard the example.

Thank you, James0628 and mlmcc.