• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 2. Selecting and Grouping Data > Crystal Reports in the Real World—Grou...

Crystal Reports in the Real World—Group 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.

1.
Open the sample report from Chapter 1 (Chap1Manual.rpt). Create a new formula and name it Group1 and click the Use Editor button.

2.
Type the following text into the code window so it appears like Figure 2.21:

WhileReadingRecords;
Select {Customer.Country}
    Case "Canada", "Mexico", "USA":
        "North America"
    Default:
        "Outside North America";

Figure 2.21. A sample formula to group information on a formula.


3.
With the text entered, click the Save And Close button.

4.
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.


5.
Click OK to see the completed report.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint