Mastering Business Analysis with Crystal Reports 9 (Wordware Applications Library)
|
The Select Expert allows you to define the filter that allows certain types of data to display within your report. This functionality is carried out through a selection statement, which is a formula that specifies the records or group of records that you want included within your report.
Selection statements are actually formulas written in the SQL language. What the Select Expert does is take the legwork (and headaches) out of writing these formulas.
To access the Select Expert and begin learning about filtering, let's create a new report.
-
In the Select Expert, press the drop-arrow to open the Comparison Operator list.
You screen should look like Figure 7-4.
Figure 7-4: The Comparision Operator list -
Set the Comparison Operator option to Is Equal To.
When you select this value, a new drop-down field displays to the right. This new drop-down field allows you to define a comparison value.
-
Select the Comparison Value drop-down field.
Click the down arrow in the right drop-down field. Select TX for Texas. You can type in TX, but make sure not to use quotation marks. Your screen should look like Figure 7-5.
Figure 7-5: The Comparison Value field Caution Databases are nitpicky when it comes to database values. A comparison value must appear exactly as it is in your report. You're usually safest choosing from the drop-down list (since these values are pulled directly from your database).
Unfortunately, these values do not always contain the comparison values you may need. If you do type in a value, make sure it exists within the database. Use the Browse button to view the values in the database.
-
Press the OK button.
A message box asks if you wish to either use saved data or refresh your data.
-
Select the Refresh Data button.
Your report refreshes, and you're returned to the Report Design area. Scroll through your pages.
Tip | By default, Crystal Reports saves records with a report the first time you preview a report. Working with saved data allows you to work with a report without constantly having to wait around for your report to refresh data from the server. Using saved data is a good idea when you're making simple formatting changes or modifying areas of the report that don't require the data to be refreshed. However, if you're changing selection statement criteria (i.e., making changes within the Select Expert), it's a good idea to always refresh your report. Not doing so might result in your report showing too few records, even though they actually exist. If you accidentally press the Saved Data button and your report doesn't return any records, press the F5 key (or Report, Refresh Report Data from the menu bar). |
You've successfully created a selection statement within your report. You should only see customers with a region equal to TX, as shown in Figure 7-6.
Removing Selection Statements
So what do you do if you wish to remove a selection statement? Crystal Reports makes removing your filters just as easy as adding them. To remove a selection statement, try the following. Use the report that you've been working on in this chapter.
-
Access the Select Expert.
-
Select the tab that contains the Region filter.
-
Press the Delete button on the Select Expert dialog box.
That particular filter is now removed.
-
Press the OK button on the Select Expert dialog box.
Crystal Reports asks if you'd like to refresh your data.
-
Press the Refresh Data button.
You're returned to the Report Design area.
-
Preview your report.
Notice that Crystal Reports removes the region filter from your report. Thus, customer information from all regions now displays.
|