Using the Standard Report Creation Wizard
The Standard Report Creation Wizard is the most often used design assistant in Crystal Reports. It provides multiple dialogs common to creating reports that are based on conventional corporate data sources. The Standard Report Creation Wizard guides you through selecting a data source, linking data source tables, adding data source fields to the report, specifying field groupings, identifying summary (total) fields, and setting the desired sort criteria for your report.
Additionally, the Standard Report Creation Wizard walks you through creating chart objects, applying record selection criteria (data filters), and applying predefined templates (layouts) to your report.
The term filter is commonly used to describe data selection criteria that narrow the scope of the data being extracted by the report from the underlying data source. For example, by using a filter such as Country = USA, you can easily limit your report to include only the information you are interested in extracting.
In total, the Standard Report Creation Wizard consists of nine dialog screens that allow you to specify the criteria mentioned previously to quickly create a professional looking report. The sequence of the wizard's dialog screens is dynamic and directly associated with the items selected in each of the progressive screens. For example, if you do not choose to identify any summary items for your report, you will not be presented with a Chart dialog screen. In general, charts apply best to summarized data, so if you have not identified any summary fields, the wizard assumes that you do not want to include a chart object in your report.
Charts can also be created from base-level data, although to do this you must appropriately specify the On Change Of option and use the Advanced settings with the Chart Expert. Generally, it makes more sense to base chart objects on summary-level data, such as regional sales by quarterwhere you are charting the total sales for each quarter rather than each sales transaction in each quarter.
It's now time to practice using the Standard Report Creation Wizard. In the following exercises, we will discuss each of the steps in the wizard and build a sales report to display last year's sales by country. By making use of the Standard Report Creation Wizard, we will include the country, city, customer name, and last year sales database fields, graphically display a summary of last year sales by country, and apply professionally styled formatting to the report.
From the Report Gallery dialog, select Using the Report Wizard in the upper portion of the screen, and then select Standard from the wizard list in the lower portion of the screen. Click OK to initiate the Standard Report Creation Wizard.
As shown in Figure 4.2, you should now be presented with the first dialoglabeled Dataas part of the Standard Report Creation Wizard. From the Data dialog screen, expand the Create New Connection node and then expand the ODBC listing as well. This should present the ODBC Data Source Selection dialog.
To expand the listing items (also commonly known as nodes), click the + sign to the left of each particular item.
Figure 4.2 The Standard Report Creation Wizard begins by requesting a data source for your report.
From the ODBC Data Source Selection dialog, scroll to the end of the Data Source Name list and select the Xtreme Sample Database 9 item, as shown in Figure 4.3. Click Next to continue.
Figure 4.3 The ODBC Data Source Selection dialog allows you to select a valid connection to access your ODBC data sources.
As illustrated in Figure 4.4, verify that the Data Source Name is correct and click Finish from the ODBC Connection Information dialog. No password is necessary to access this database.
Figure 4.4 The ODBC Connection Information dialog asks you to verify the connection information to access your ODBC data sources.
After you have successfully identified and connected to Xtreme Sample Database 9, you should see this item listed under the ODBC node in the Available Data Source area of the Data dialog screen, as shown in Figure 4.5. Upon expanding the Xtreme Sample Database item, you should see three distinct data source items listed: Tables, Views, and Stored Procedures (shown in Figure 4.6) .
Figure 4.5 The Xtreme Sample Database will be listed under the Available Data Sources area of the Data dialogscreen.
Figure 4.6 Upon expanding the Xtreme Sample Database item, you will notice multiple database items listed.
Within the Data dialog screen, select the Customer and Orders tables so that they are listed in the Selected Tables area on the right (as shown in Figure 4.7). After these two tables are selected, click Next to continue.
There are multiple ways to include tables in your report from within the Data dialog screen. From the list of available tables on the left side of the dialog, you can perform any one of the following actions to populate the Selected Tables list on the right side of the dialog area:
Double-click on each desired table item
Drag-and-drop each desired table item
Highlight the table item on the left and click on the respective arrow icons (> or >>)between the two listing areas to populate the listing on the right
Figure 4.7 The Customer and Orders tables should now be listed in the Selected Tables area.
The Link dialog screen presents a visual representation of the relationship between these two tables and permits you to modify the defined relationship by specifying the exact Join links that you require to accurately report on the data within the selected tables. As shown in Figure 4.8, you should now see the Link dialog screen. For our purposes here, we will accept the default Join condition. Click Next to continue.
Figure 4.8 The Customer and Orders tables are linked together via the Customer ID field.
What Is a Link?
A link is often described as a field common to two or more database tables, which serves as a connecting point between those database tables. Crystal Reports uses the link to match up records from one database table with those from one or more other database tables. For example, if two database tables each contain a Customer ID field (even though the fields might have different names), Crystal Reports can use these fields to electronically connect the records in one database table with the corresponding records in the other table. As a point of reference, the term link in Crystal Reports is equivalent to the term relationship in Microsoft Access. See Hour 3 for more details on Join types.
After specifying the table linking, you will see the Fields dialog screen, shown in Figure 4.9. Select the Country, City, Customer Name, and Last Year's Sales fields so that they appear under the Fields to Display area on the right. If necessary, you can use the up and down arrows to modify the order of these fields in the list. Click Next to continue.
Figure 4.9 The Country, City, Customer Name, and Last Year's Sales fields should appear under the Fields to Display area.
You should now see the Grouping dialog screen. This dialog allows you to
identify logical groups of information within your reports. For this example,
select to group by the Country field only, as shown in Figure 4.10. Click Next
The Summaries dialog screen allows you to identify summary values to complement the report's structure and how you want to present the information within your reports. If you do not identify any grouped items in a report, you will not see the Summaries dialog because summaries are only applicable to grouped data. For example, if you are grouping your report according to the country field, you might want to see a sum of last year's sales figures for each country group.
Figure 4.10 The Grouping dialog allows you to create structured groupings of information within your report.
You should now see the Summaries dialog screen. To apply a summary object to the report, select the Last Year's Sales field so that it appears under the Summarized Fields list on the right. This is shown in Figure 4.11. Click Next to continue.
As you might notice, Crystal Reports automatically chooses a summary for you if you choose to group your report data. It will examine the detail information you've specified for the report and build a summary on the first available numeric field. However, this default summary criteria can easily be modified.
Figure 4.11 The Summaries dialog screen allows you to create summarized values that are frequently used in coordination with the grouping structure within reports.
By default, the Last Year's Sales field that appears under the Summarized Fields area on the right is aggregated as a Sum of the actual field value. As shown in Figure 4.11, the drop-down list located in the lower-right area of the Summaries dialog screen allows you to select from a variety of summaries, including Sum, Average, Maximum, Minimum, Count, Correlation, Covariance, and Standard Deviation.
We will now sort the report based on last year's sales of the top five countries. The Group Sorting dialog screen allows you to sort the grouped fields based on the summarized totals. From the Group drop-down list, select the Country field (the only option in our example here) and select the Top 5 Groups option from the Group Ordering choices. Also, select the Sum of Last Year's Sales item from the Comparing Summarized Values drop-down list, as shown in Figure 4.12. Click Next to continue.
Figure 4.12 The Group Sorting dialog allows you to sort your report based only on the Group values that you want to include in the report results.
Let's add a chart to visually display the top five performing countries according to last year's sales. From the Chart dialog screen, you can select a chart object to be included in the report based on the group and summary items you identify here. For our example, we will add a bar chart and select the Country field from the On Change Of drop-down list and the Sum of Last Year's Sales item from the Show Summary drop-down list. Change the chart title to read, Last Year's Sales by Countrysee Figure 4.13 for additional guidance. Click Next to continue.
Figure 4.13 The Chart dialog allows you to select a chart object for your report based on the previously identified group and summary criteria.
Let's assume that we are only interested in customer records in which last year's sales are greater than $1,000. The Record Selection dialog screen allows us to identify selection criteria, often called data filtering, to isolate the resultset of the report to include only the information we are interested in returning. We make this distinction by selecting Last Year's Sales as the Filter Field, choosing Is Greater Than from the filter operators drop-down list, and typing in 1000.00 in the value drop-down list, as shown in Figure 4.14. Click Next to continue.
Figure 4.14 The Record Selection dialog permits you to narrow your resultset based on the selection criteria identified here.
Finally, we will apply a predefined style to our report. From the Template dialog screen, you can select predefined styles to be applied to your report for formatting purposes, as shown in Figure 4.15. The Available Template list includes various sample templates that are included with the Crystal Reports 9 installation. However, you can also create your own templates to be used for report formatting. For this example, select the Block Sample (Blue) template. For additional details on how to design and implement your own templates, see Hour 19, "Designing Effective Report Templates."
Figure 4.15 The Template dialog permits you to select predefined styles to be applied to your report.
This now concludes the Standard Report Creation Wizard example. After you click Finish, you will execute the report that you have just created and will be presented with the preview of the corresponding resultset. At this point, you can click Finish if you are satisfied with the report design criteria. When you are presented with the preview of you report, save your new report by selecting Save As from the File menu. Name this report StdReportWizard1.rpt.
In Crystal Reports terminology, a template can be a copy of a report used as the starting point for creating a new report, or it can be a report whose formatting and functionality is applied to a new report created in the Standard Report Creation Wizard. As it relates to this exercise, you are using a report template to apply one of several professionally designed styles to your report for formatting purposes only. Regardless of which method is used, when acting as a template, the original report remains unchanged.
After you select Finish at the end of the Standard Report Creation Wizard process, you will be presented with the executed resultset and a preview of your newly created report. As Figure 4.16 shows, creating a useful and professional looking report is extremely simple when using the Standard Report Creation Wizard. In the preceding exercises, you have connected to a database, identified the tables and fields you wanted to include in your report, linked the tables together, grouped and summarized the data, sorted the data, applied filtering criteria, included a chart object for enhanced visualization of the report results, and applied a report template for quick and easy formattingall in just a few clicks of your mouse! This process speaks both to the ease of use and power of the Crystal Reports design application.
Figure 4.16 The executed resultset and preview of the report you have just created using the Standard Report Creation Wizard.