Crystal Reports Formula

Posted on 2013-02-04
Last Modified: 2013-02-06
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)
Question by:Mark01
  • 4
  • 3
  • 3
LVL 100

Expert Comment

ID: 38853468
What is your issue?


Author Comment

ID: 38853592
Field and table namesHi mlmcc,

I don't know how to write the formula(s). This image may help.
LVL 100

Expert Comment

ID: 38853624
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 35

Expert Comment

ID: 38854402
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.


Author Comment

ID: 38856231
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.
LVL 35

Expert Comment

ID: 38856699
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.


Author Comment

ID: 38857475
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.
LVL 100

Assisted Solution

mlmcc earned 250 total points
ID: 38858032
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?

LVL 35

Accepted Solution

James0628 earned 250 total points
ID: 38858788
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 ...)?


Author Comment

ID: 38862158
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.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question