Crystalkeen logo; we offer Crystal reports viewers and schedulers
 
Crystalkeen header image 3
Crystalkeen header image 5

Crystal Reports Tools: Improve Performance While Saving Time and Money

Crystal Reports:
Running total using formulas with variables

Running totals in versions 5 and 6.

Prior to version 7 of Crystal Reports, the running total field was not available. Reports could display a value that calculated a running total.

How do you do this? You need two formulas: one to set a variable to zero, and a second formula to accumulate a field into that variable. To behave correctly, all variable formulas need to be calculated WhilePrintingRecords

Formula: Reset Total. Insert this formula in the Report Header or Group Header section and suppress the field

WhilePrintingRecords; NumberVar Amount :=0;

Formula: Calculate Total. Insert this formula in the Details Section

WhilePrintingRecords; NumberVar Amount := Amount + {Order.Amount};

//Where {Order.Amount}; is the field you are interested in totaling.

Sometimes a third formula is needed to display the value in the variable without accumulating again.

WhilePrintingRecords; NumberVar Amount

You can also:

The above article isn't particularly useful to the vast majority of Crystal Reports designers, because we are way past version 6 now. However, even later users can understand the technique used and apply it to other needs that arise in later versions of Crystal Reports.

It's also worth noting that there's still a huge installed base of pre-Version 7 out there. Many of these are embedded in other applications, and there's really no reason to upgrade to a newer version of Crystal Reports.

Yet sometimes a new requirement comes along, for example an executive wants to see running totals and you have version 5. Upgrading to a current version of Crystal Reports would be hugely expensive in this case because you'd have extensive recoding or upgrading of the other application, etc.

It might be prudent to ditch the current system entirely, and replace it with something standalone that doesn't use Crystal Reports. But then you're starting over in so many ways. Being able to meet that new requirement with a few lines of code makes it so that whole headache doesn't need to happen.

Here's a tip, if you have budget issues but want better report distribution:

See our Crystal Reports schedulers and Crystal Reports viewers.

Here are a couple of videos to help you with this topic:

 

This article is copyrighted by Crystalkeen, Mindconnection, and Chelsea Technologies Ltd. It may be freely copied and distributed as long as the original copyright is displayed and no modifications are made to this material. Extracts are permitted. The names Crystal Reports and Seagate Info are trademarks owned by Business Objects.

Authorship

Except where an author's name is given at the start of the article, all of these articles were written by Mo Naughton or Bruce Ferguson and edited by Mark Lamendola. Mo is a Crystal Reports consultant, trainer, and developer for Chelsea Technologies, Inc. Bruce Ferguson is a Crystal Reports consultant, trainer, and developer for CrystalKiwi, Inc. Mark Lamendola is a writer and editor with over 15 years experience in professional and trade publications.

 

  • Questions? Please write to mark@crystalkeen.com. We do want your business.
  • Do you have your own tips for Crystal Reports administrators and designers? Write to mark@crystalkeen.com and we'll post your tips with a link to your Website (or with some other attribution if you choose).
  • Crystal Reports is a subsidiary of Business Objects, which is owned by SAP.