Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

7.01 Introducing Formulas

Formulas enable you to customize report output by analyzing the data in the report as it is being printed. There are two circumstances when you need to use formulas. The first is performing calculations based on the raw data. For example, when printing the monthly sales for a product you can calculate the percent of total sales. Storing this in the database isn’t practical because it is more efficient to calculate that value on an as needed basis rather than waste space storing the number in the database. The second circumstance that formulas are needed is dynamically modifying the formatting of fields or sections on the report. For example, you can simulate a “green bar” report by using a formula that alternates the background color of every other row. The flexibility and power of formulas make them one of the most useful features of Crystal Reports.

This chapter is the first of three that show you how to use formulas to make reports vibrant. It shows you when and how to use the Formula Editor. The next chapter is a syntax primer for both Basic syntax and Crystal syntax. These are the two languages that Crystal Reports uses. Chapter 9 is a reference for the common functions that are built into Crystal Reports.

Throughout this chapter, the examples are written using Basic syntax. Although this language isn’t covered in this chapter, it is very much like VB .NET and you shouldn’t have any problem understanding the examples here. In fact, the two languages are so similar that you might be tempted to skip over the next two chapters if you already know how to program in VB .NET. I don’t recommend this because Basic syntax has been designed to make reporting easier, and it adds a lot of new functionality not found in VB .NET. Learning about this new functionality can show you how to simplify some reporting specific tasks that would be more difficult that in VB .NET.