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.

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


Receipts Sum 1:

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

Beginning Balance:

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


There are other fields so the tables can JOIN appropriately.

babdDate :DateTime (field)

AccountNumber :Text (field)

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

brkReceiptDescr :Text (field)

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

BrokerageAccountID(Long) (field)
BrkgAcctBalDateID(Long) (field)
brkbdBalnce :Currency (field)
Who is Participating?
James0628Connect With a Mentor Commented:
As mlmcc said, it depends on your data, and your report structure.

 If you want each line to show the total so far for the group/report (on the first line you get the amount from that line, on the second line you get the total for the first two lines, and so on), that's what a running total is.  OTOH, a regular summary will always give you the total for the entire group/report.  CR running totals also give you more control over which records they include.

 In your "desired version" examples, you show the first account twice, at the beginning and again at the end.  Do you actually want accounts to appear twice on the report?  If so, that complicates things.  Exactly where do you want the accounts to be repeated (group footer or ...)?

What is your issue?

Mark01Author Commented:
Field and table namesHi mlmcc,

I don't know how to write the formula(s). This image may help.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

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

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.

Mark01Author Commented:
CR table linksCurrent Reportmlmcc 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.
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.

Mark01Author Commented:
Desired VersionCurrent VersionThe 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.
mlmccConnect With a Mentor Commented:
There is no "BEST" way to calculate totals.  It all depends on the data.

If you just need the totals and are getting only 1 record for each receipt for a given date then you can group the report on the receipt type and use the summary functions to get the total for that group

If you are getting duplicate records, running totals or manual totaling through formulas are the easiest way to go.  

Can you upload the rpt file?

Mark01Author Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.