Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

A.33 Tutorial A-3 Single Year Income Statement, Part 2

In the balance sheet report, we created a formula called Amount that was used in calculating the sub-total for each account. This formula used Table A-1 to determine whether a balance should be positive or negative based upon the account type and whether it was a debit or credit. The same rules that apply for a balance sheet apply for the income statement. We are just going to copy that same formula to this report.

  1. In the Field Explorer window, right-click the Formula Fields category and select New.
  2. For the formula name, enter Amount.
  3. In the Formula Workshop window, enter the following formula:

if {Account_Type.Account Type} = "Asset" Then
if {Journal_Entry.Debit Or Credit} = "Debit" Then
{Journal_Entry.Amount}
Else
{Journal_Entry.Amount} * -1
Else
if {Journal_Entry.Debit Or Credit} = "Credit" Then
{Journal_Entry.Amount}
Else
{Journal_Entry.Amount} * -1

  1. Click the Save and Close button to check for errors and save your changes.
  2. The bottom half of this formula is really the only portion necessary for the income statement because it handles the revenue and expense accounts. The first half of the formula handles assets which only appear on the balance sheet. I’m using the same formula on both reports for consistency purposes, as well as, making sure that it stays compliant with the rules in Table A-1.
  3. Drag and drop the {@Amount} formula onto the Details section of the report. Even though the Details section is suppressed and the {@Amount} balance won’t be displayed, this makes it easy for us to add sub-totals to the group footers.
  4. Delete the Amount column header that Crystal Reports added to the report automatically when you dropped the formula onto the report.
  5. Right-click on the {@Amount} formula in the Details section and select Insert > Summary.
  6. On the Insert Summary dialog box, click the Summary Location drop down box and choose Group #3.
  7. Click the OK button to save your changes and insert the summary field into group #3.
  8. Click on the summary field and turn off the bold formatting so that the font matches the group #3 field.
  9. Right-click on the {@Amount} formula in the Details section and select Insert > Summary.
  10. On the Insert Summary dialog box, click the Summary Location drop down box and choose Group #2.
  11. Click the OK button to save your changes and insert the summary field into group #2.
  12. Click on the summary field and turn off the bold formatting so that the font matches the group #2 field.
  13. For the report sections (e.g. Gross Margin, Operating Income, etc.), we can’t add a summary field to the group footer because the balances are not sub-totals of the accounts within that section. Instead, each section balance is a running total of all the balances that came before it. We need to add a running total field and put it in the group footer for the section group.
  14. Right-click on the {@Amount} field in the Details section and select Insert > Running Total. This opens the Create Running Total Field dialog box.
  15. For the running total name, enter Section Balance.
  16. Click the OK button to save your changes and insert the running total onto the report.
  17. Crystal Reports automatically put the running total field in the Details section. Drag it into the group #1 footer and line it up with the summary field in group #2.
  18. Set the format of the running total field to bold.
  19. Delete the running total’s column header field that was automatically placed on the Page Header section by Crystal Reports.
  20. At this point, we are almost finished. If you look at the report, you’ll see that each group has a balance associated with it. The account class groups show the sub-totals of the account balances within each category and the sections print the running total balances. This is shown in Figure A-11.



Figure A-11. Income statement preview with balances.