Group on a Formula
Sometimes when creating a report, the development database might not be complete or in some cases even in production, there might be a requirement to group elements based on some criteria that is not in the database.
In situations such as these, it can be useful to group on a formula (this will be covered in more detail throughout the book).
Crystal Reports in the Real WorldGroup on a Formula
Sometimes when creating a report, the development database might not be complete or might be in production; there might be a requirement to group elements based on some criteria that is not in the database. In these cases, it can be useful to group on a formula. The formula needs to meet some criteria that will be explained in greater detail in later chapters.
- Open the sample report from Chapter 1 (Chap1Manual.rpt). Create a new formula and name it Group1 and click the Use Editor button.
- Type the following text into the code window so it appears like Figure 2.21:
Case "Canada", "Mexico", "USA":
"Outside North America";
Figure 2.21. A sample formula to group information on a formula.
- With the text entered, click the Save And Close button.
- From the Report menu, select Group Expert. Find the Group1 formula from the list of Available Fields and add it to the list of Group By fields. Finally, because the Group1 field is a higher level than the For Country field, select it and move it up using the arrow button. The results are displayed in Figure 2.22.
Figure 2.22. The report correctly grouped, highlighting the capability to group on formulas and create increasingly flexible reports.
- Click OK to see the completed report.