Understanding the Formula Workshop Windows
The Formula Workshop lists all available fields, formulas and operators. It makes it possible to almost write your formulas without doing any typing. Just double-click the appropriate functions and report fields and let the formula be built for you. Personally, I don’t find this very practical on a regular basis. Scrolling through a hierarchy of syntax trees isn’t nearly as efficient as just typing it in. However, it is very useful to have these trees available when you can’t remember something. It also shows you all the arguments a function requires. These windows are almost like having a mini-help file available. Each window is explained in more detail next.
As mentioned earlier, there are four primary windows that make it easier for you to write formulas. They are shown here again for review.
Workshop Tree Window
The first window, the Workshop Tree, shows you the existing formulas. Rather than having to remember the names of all the database fields and function names, each is listed in one of these windows. When you double-click any of the items, that item appears in the Definition area at the bottom. You can also drag and drop the item into the code window.
Figure 5-5. The Workshop Tree window.
The Workshop Tree lists every formula stored in the report. It breaks them down by the following categories:
Report Custom Functions are functions that you create and can be shared among all formulas in the report. Custom functions store common functionality that needs to be used in different places throughout the report. This is discussed in more detail in Chapter 6.
Repository Custom Functions are custom functions stored in Crystal Reports Server. They are shared among different reports within the enterprise.
Formula Fields perform calculations and implement conditional formatting. They are the focus of this chapter.
SQL Expression Fields are used directly with your database server. The formula only calls functions that are compatible with the database. This is discussed in more detail in Chapter 11.
Selection Formulas were discussed in Chapter 4. They determine which data is shown on the report and which data gets filtered out.
Formatting Formulas list the report sections and objects and show the conditional formulas associated with them. It lists each section of the report as a node and by expanding the node you see every report object in that section. If an object has conditional formatting applied to one of its properties then you’ll see that listed as well. If you recall from Tutorial 5-1, we added conditional formatting to the Background Color property of the Details section.
Report Fields Window
Located to the right of the Workshop Tree window is the Report Fields window. It lists every field used in the report as well as every field available from the report’s data source.
Figure 5-6. The Report Fields window.
The first node listed is the Report Fields node. By expanding it, you’ll see each field currently used in the report. This makes it easy to quickly find and reference a report field in another formula. The second node shows the report’s data source. Expand it to see every field available in the tables. This lets you reference a field in your formula even if the field isn’t being used on the report.
Formula Functions Window
The Formula Functions window shows all the functions available.
Figure 5-7. The Formula Functions window.
At first, this tree is a nice crutch to lean on as you learn the Crystal Reports programming language. As you get better at writing formulas you will quickly learn the language and not rely on the Function Tree.
Report Operators Window
The Report Operators window shows all the available operators that can be used in a function.
Figure 5-8. The Report Operators window.
Just like the other windows, the Report Operators window shows them grouped by category. Some of these categories are Arithmetic, Boolean, Comparisons, etc. It is similar to the Function Tree in that it is a nice crutch when you are new to writing formulas, but you may outgrow it with enough practice.