You are on page 1of 156

Cr y s t a l Re p o r t s XI :

Ba s i c
Instructors Edition
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
ILT Series



COPYRIGHT Axzo Press. All rights reserved.
No part of this work may be reproduced, transcribed, or used in any form or by any meansgraphic, electronic, or
mechanical, including photocopying, recording, taping, Web distribution, or information storage and retrieval
systemswithout the prior written permission of the publisher.
For more information, go to www.courseilt.com.
Trademarks
ILT Series is a trademark of Axzo Press.
Some of the product names and company names used in this book have been used for identification purposes only and
may be trademarks or registered trademarks of their respective manufacturers and sellers.
Disclaimer
We reserve the right to revise this publication and make changes from time to time in its content without notice.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE


Co n t e n t s

Introduction iii
Topic A: About the manual............................................................................... iv
Topic B: Setting student expectations .............................................................. ix
Topic C: Classroom setup................................................................................. xi
Topic D: Support.............................................................................................. xiv
Getting started 1-1
Topic A: The Crystal Reports environment ..................................................... 1-2
Topic B: Creating, viewing, and saving reports ............................................. 1-12
Topic C: Modifying report layout................................................................... 1-24
Topic D: The Help feature .............................................................................. 1-32
Unit summary: Getting started ........................................................................ 1-34
Formatting 2-1
Topic A: Absolute formatting.......................................................................... 2-2
Topic B: Introducing conditional formatting.................................................. 2-14
Unit summary: Formatting.............................................................................. 2-17
Sorting and selecting records 3-1
Topic A: Sorting records.................................................................................. 3-2
Topic B: Selecting records............................................................................... 3-4
Unit summary: Sorting and selecting records ................................................. 3-10
Grouping and summarizing 4-1
Topic A: Groups .............................................................................................. 4-2
Topic B: Summaries ....................................................................................... 4-10
Unit summary: Grouping and summarizing.................................................... 4-17
Formulas and functions 5-1
Topic A: Formulas ........................................................................................... 5-2
Topic B: Modifying formulas.......................................................................... 5-7
Topic C: Functions ......................................................................................... 5-10
Unit summary: Formulas and functions .......................................................... 5-21
Experts and wizards 6-1
Topic A: The Database Expert......................................................................... 6-2
Topic B: Report wizards.................................................................................. 6-6
Topic C: Cross-tab reports.............................................................................. 6-13
Unit summary: Experts and wizards ............................................................... 6-20
Distributing reports 7-1
Topic A: Exporting reports .............................................................................. 7-2
Topic B: Delivering reports ............................................................................ 7-13
Unit summary: Distributing reports ................................................................ 7-16
Course summary S-1
Topic A: Course summary............................................................................... S-2
Topic B: Continued learning after class .......................................................... S-4
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
ii Crystal Reports 11: Basic

Quick reference Q-1
Glossary G-1
Index I-1


P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
11

Un i t 1
Getting started
Unit time: 120 minutes
Complete this unit, and youll know how to:
A Discuss the main features of Crystal
Reports, use the Start Page, open a report,
explore the Crystal Reports environment,
modify a report section, and set file
options.
B Create a new report, add fields to a report,
change the page orientation, and view and
save a report.
C Modify a reports appearance by sizing,
arranging, and aligning its fields.
D Use Help.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
12 Crystal Reports 11: Basic

Topic A: The Crystal Reports environment
Explanation Crystal Reports helps you analyze and interpret data, as well as present it in an easy-to-
read format. Crystal Reports works with other programs that act as data sources, usually
a database. The program can be used to create both simple and complex reports using
almost any data source. Crystal Reports tools guide you through building reports and
using maps and graphs.
Crystal Reports features

With Crystal Reports you can report on data from a number of different sources,
including dBASE, FoxPro, Clipper, Pervasive, Paradox, Microsoft Access, and
Microsoft SQL Server. Some of its features include:
The Database Expert, which you use to connect to a data source and to maintain
a list of recently used data sources
The Field Explorer, which you can use to insert, edit, or delete fields in a report
The ability to export reports to other formats, including Microsoft Excel or
Microsoft Word
The ability to quickly create appealing reports using custom templates
Support for Unicode strings to show reports in multiple languages
Seamlessly managed access to multiple dissimilar data sources
Integration into .NET, JAVA, and COM applications
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 13

Do it! A-1: Discussing the features of Crystal Reports
Questions and answers

1 Why might you use Crystal Reports?
To present data in an easy-to-read format

2 From where does Crystal Reports access data?
A data source, such as Microsoft Access or Microsoft SQL Server

3 What is the purpose of the Database Expert?
To connect to a data source

4 What is the purpose of the Field Explorer?
To insert, edit, or delete fields in a report

5 Your manager wants to see one of your reports, but does not have Crystal Reports
installed. How can you present the report?
Export it to another format, such as Microsoft Excel or Microsoft Word.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
14 Crystal Reports 11: Basic

The Start Page
Explanation When you start Crystal Reports, it displays the Start Page, as shown in Exhibit 1-1.
From here, you can open an existing report, create a new one, or view a sample report.
The Start Page will also list recently opened reports. In addition, the Start Page provides
a place to search for information on a particular topic, either in the programs built-in
Help feature, or from a selection of online resources.


Exhibit 1-1: The Crystal Reports Start Page
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 15

Do it! A-2: Examining the Start Page
Heres how Heres why
1 Choose Start, All Programs,
Crystal Reports XI
To start Crystal Reports XI. The Crystal Reports
Start Page opens. Maximize the window, if
necessary.
2 In the Workbench pane, on the
right, click
To close the Workbench. Youll learn about the
Workbench later.
If the Business
Objects Registration
Wizard dialog box opens,
tell students to click
Register Later.
Tell students that the
Workbench will be
covered in the Advanced
course.
3 Observe the screen The Start Page contains options for opening
existing reports, creating new reports, and for
finding resources about the Crystal Reports
program.

4 Under Getting Started, uncheck
Show online resources
To hide the Resources Online section of the
Start Page.

Recheck Show online
resources
Youll go online to learn more about Crystal
Reports.
5 In the Resources Online section,
under Are You A New User?,
click Find out whats new in
Crystal Reports XI
To go to the Whats New in Crystal Reports XI
web page.
If a privacy dialog box
opens, have students
verify that Dont show this
message again is
checked, and click OK.
If time permits, allow
students to look over the
web page.
Close the browser

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
16 Crystal Reports 11: Basic

Opening reports
After you start Crystal Reports, you open a report by performing these steps:

1 Choose File, Open.
2 From the Look in list, select the folder containing the report.
3 In the folder, select the report you want to open.
4 Click Open.
Once you have opened a file, you can open it again via the Recent Reports section of the
Start Page.
Do it! A-3: Opening a report
Heres how Heres why
1 Choose File, Open To display the Open dialog box.
2 From the Look in list, navigate to
the current unit folder

Tell students that
they can also click Open
File on the Start Page.
Help students navigate to
the current unit folder.
Select Sales report
Tell students they
can also double-click the
report to open it.
3 Click Open To open the report.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 17

The Crystal Reports environment
Explanation The Crystal Reports window contains a title bar, a menu bar, and the Standard,
Formatting, Insert, Experts, and Navigation Tools toolbars, as shown in Exhibit 1-2.
The title bar displays the name of the program and the title of the active report. You use
the menu bar and the toolbars to interact with the program and your reports.


Title
bar
Menu
bar
Standard
toolbar
Formatting
toolbar
Insert
Tools
toolbar
Expert
Tools
toolbar
Navigation
Tools
toolbar

Exhibit 1-2: Some components of the Crystal Reports window
As shown in Exhibit 1-3, the Crystal Reports window also displays tabs for the Start
Page, the current report, and Design view. Tabs provide a convenient way to switch
between different views of a single report, between different reports, and between a
report and the Start Page.
In addition, the Crystal Reports window contains the status bar, which provides you
with information about your current report.


Design tab
Status bar
Start Page tab Report tab

Exhibit 1-3: More components of the Crystal Reports window
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
18 Crystal Reports 11: Basic

The Design tab
Explanation You use the Design tab to create reports. Here, you can add fields and other objects such
as text and images, and arrange them as you see fit. These fields and objects represent
the data that will appear in the report, but you must either preview or print the report to
see the actual data.
The following table describes the sections of a report.

Section Description

Report Header Contains objects that will appear only at the beginning of the report, such as a company
logo or a title.
Page Header Contains objects that will appear at the top of each page, such as field headings.
Details Contains the body of the report.
Report Footer Contains objects that will appear only at the end of the report, before the last page
footer, such as grand totals.
Page Footer Contains objects that will appear at the bottom of each page, such as page numbers.

Do it! A-4: Examining the Design tab
Heres how Heres why

1 Activate the Design tab (If necessary.) Click on it.

2 On the Design tab, observe the
Report Header section
It contains the Report Title and Print Date fields.
These items will appear only once, at the top of
the report.

3 Observe the Page Header section It contains the report objects Transaction code,
Transaction date, Product code, Retailer code,
Quantity sold, and Order value. These are text
objects that will act as field headings on each
page of the report.
Tell students that they will
learn about formula fields
later.
4 Observe the Details section It contains the fields Transaction_code,
Transaction_date, Product_code, Retailer_code,
Quantity_sold, and the formula field
@Order_value. These will be populated by data
from the data source.

5 Observe the Report Footer section It contains a grand total for the Order_value
field and a text item that identifies that total.

6 Observe the Page Footer section It contains a field that will display the current
page number and the total number of pages at
the bottom of each page.

7 Choose View, Print Preview (Or click the Preview tab.) To preview the
report. The Preview displays how the report will
look when printed.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 19

Modifying report sections
You may wish to change the sizes of various sections of a report to enhance the
readability of your data. Sometimes, however, this can result in data that is too spread
out to be easily viewed, or in more white space than you want. When this happens,
Crystal Reports offers a way to quickly revert the section to its original size.
Do it! A-5: Modifying the size of the Details section
Heres how Heres why

1 Activate the Design tab To return to Design view.

2 In the report, position the mouse
pointer on the bottom line of the
Details section, as shown

The pointer turns into a double arrow, indicating
that the line can be moved.

Drag down slightly, as shown


3 Activate the Preview tab To preview the report. The data is spread out
over a larger space.

4 Switch to Design view

5 In the Details section header,
right-click and select Fit
Section from the context menu
To return the Details section to its original size.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
110 Crystal Reports 11: Basic

File options
You can set various options for your reports by using the Options dialog box. For
example, you may want to change the default font used for field values, or you might
want to show guidelines to assist you in placing fields and text objects.
To set file options using the Options dialog box, choose File, Options. Click the tab you
want to specify options for, and make your desired selections.
Do it! A-6: Setting file options
Heres how Heres why

1 Choose File, Options To open the Options dialog box.

2 Activate the Layout tab If necessary.

Observe the screen The Layout tab contains options designed to
help you with the layout of fields and text
objects.

3 Under Design View, verify that
Rulers is checked
To ensure that rulers are shown on the Design
tab.

4 Under Grid options, verify that
Snap to Grid is checked
To ensure that when fields are placed in the
report, they will align to the default grid.

5 Under Field options, uncheck
Show Field Names
To hide the names of fields in the report.

Click OK To close the Options dialog box.

6 Observe the report The field names have been replaced with Xs for
text fields, and a symbolic number for number
fields.

7 Open the Options dialog box Choose File, Options.

Under Field Options, check
Show Field Names
To show the field names in the report.

8 Activate the Fonts tab To view the options for changing the default
fonts for various fields.

Click Fields To see the default font for ordinary text fields.

Observe the defaults The default font face is Arial, the default style is
Regular, and the default size is 10. Here you can
choose different font faces and styles, as well as
colors, if you wish.

Click Cancel To close the Font dialog box without making
any changes.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 111



9 Click OK To close the Options dialog box.

Observe the report The field names are displayed again, because
you checked that option on the Layout tab.

10 On the Sales report tab, click
To close the report.

In the message box, click No To close the report without saving changes.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
112 Crystal Reports 11: Basic

Topic B: Creating, viewing, and saving reports
Explanation You can design your own reports from scratch, or you can create them by using Report
wizards. Report wizards guide you step-by-step through the process of creating a report,
and make a complicated set of tasks simple to accomplish. However, you should design
a report from a blank report document when full flexibility and control of design is
needed, or when the report type you want is different from the standard report types
available in the wizards.
In general, creating reports includes two high-level tasks:
Selecting the data source by using the Database Expert dialog box
Adding fields by using the Field Explorer dialog box
Creating reports and the Database Expert
After you choose the type of report you want to create, you then need to select a data
source for the report by using the Database Expert dialog box. This dialog box provides
a list of folders containing possible data sources for your report, as shown in Exhibit 1-
4.



Exhibit 1-4: The Database Expert dialog box
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 113

The following table describes the folders that appear in the Database Expert dialog box.

Folder Description

Current
Connections
Contains the list of data sources that you are currently using

Favorites Maintains a list of commonly used data sources

History Maintains a list of recently used data sources

Create New
Connection
Maintains a list of subfolders for data sources you can connect to

Repository Maintains a list of data source connections that is stored in the repository

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
114 Crystal Reports 11: Basic

Do it! B-1: Creating a new blank report
Heres how Heres why
1 On the Start Page, select Blank
Report
To open the Database Expert dialog box. Youll
create a new report from scratch and select a
data source for your report.
Tell students that they will
learn about working with
wizards elsewhere in the
course.
2 Observe the Database Expert
dialog box
The Current Connections folder is selected.

3 Double-click Create New
Connection
(Or click the plus sign.) To view the subfolders
under this option.

4 Double-click
Access/Excel (DAO)
To open the Access/Excel (DAO) dialog box.

Click
(On the right side of the Database Name box.)
To open the Open dialog box.

5 Navigate to the current unit folder If necessary.

Select Employees

Click Open To close the Open dialog box and return to the
Access/Excel (DAO) dialog box.

6 Observe that the database path
selected appears in the Database
Name box
This is where Crystal Reports will get the data
for your report.

Click Finish To close the Access/Excel (DAO) dialog box
and return to the Database Expert dialog box.
.
7 Select the indicated table


Click
To add the Employees table to the Selected
Tables list box.

8 Click OK To close the Database Expert dialog box.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 115

The Field Explorer
Explanation After youve selected a data source, you can use the Field Explorer dialog box to add
fields to your report. The Field Explorer dialog box, shown in Exhibit 1-5, displays a
tree view of the types of fields you can use: database, formula, SQL expression,
parameter, running total, group name, and special fields.



Exhibit 1-5: The Field Explorer dialog box
The following table describes the branches of the Field Explorer dialog box:

Branch Description
Database Fields Used to add fields stored in a database. For example, database fields
from a Customer database might include Customer Name, Address,
City, State, Zip Code, and Phone Number.
Formula Fields Used to create, edit, rename, delete or insert fields that display
calculated values.
SQL Expression
Fields
Used to create, edit, rename, delete or insert SQL Expression Fields.
Parameter Fields Used to create, edit, rename, delete, or insert fields that prompt the
report user for input. For example, a parameter field in a sales report
might prompt the user to enter the name of a product.
Running Total Fields Used to create, edit, rename, delete, or insert Running Total fields.
Group Name Fields Used to insert an existing Group Name field.
Special Fields Used to add information, such as the page number, file creation date,
print date, or report title.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
116 Crystal Reports 11: Basic

Adding fields to a report
To add a field to a report, click the Field Explorer button on the Standard toolbar, or
choose View, Field Explorer. Then, select the desired field from the Field Explorer and
drag it into the report. When you drag a database field to the Details section, Crystal
Reports also creates a text object containing the fields name in the Page Header section.
Text objects are generally used to insert labels, titles, and summaries. After you have
added a field to the report, a green checkmark appears next to the field in the Field
Explorer.


Exhibit 1-6: The preview of a portion of the report created in the activity
Do it! B-2: Adding fields by using the Field Explorer
Heres how Heres why
1 On the Standard toolbar, click


Or choose View, Field Explorer To display the
Field Explorer. By default, Database Fields is
selected.
Tell students that
they will be creating an
Employee Details report
for Outlander Spices.
2 Expand Database Fields Double-click it or click the plus sign next to it.

Expand Employees To display the fields in the Employees table.

3 Drag Employee_code from
the Field Explorer to the Page
Header section


Observe the report The field is in the wrong section. Database fields
need to go into the Details section.
Tell students that the
Undo button is useful for
correcting mistakes.
4 On the Standard toolbar,
click
The Undo button. To undo the field insertion.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 117


Show students where to
place the fields.
5 Drag Employee_code from
the Field Explorer to the Details
section, as indicated
In the Page Header section, a text box
containing the fields name appears. In the Field
Explorer dialog box, a check mark appears next
to Employee_code.

6 Select the First_name field

While pressing c, click
Last_name, Region,
Department, and Earnings in
the Field Explorer
To select them.

Position the pointer on the
First_Name field, and drag to the
Details section
To add all the selected fields to the report at
once.

7 In the Field Explorer, expand
Special Fields
To display the Special Fields list.

Drag Page Number from the
Field Explorer to the Page Footer
section of the report
(Scroll down in the Field Explorer dialog box, if
necessary.)

8 In the Field Explorer, click
The Auto-hide button. To hide the Field
Explorer in order to see more of the report.

Click anywhere in the report To hide the Field Explorer, and deselect the
fields in the report.

9 Choose View, Print Preview To preview the report. The Preview tab is added
next to the Design tab, showing a report
resembling Exhibit 1-6. Scroll down to see the
page number.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
118 Crystal Reports 11: Basic

Page setup
You may find that the default page orientation of a report doesnt display all the fields
you included. In that case, you can change the reports orientation to accommodate the
additional fields. To do so, choose File, Page Setup to open the Page Setup dialog box,
and choose Landscape as the page orientation.
Do it! B-3: Changing the page orientation of a report
Heres how Heres why

1 On the Preview tab, observe the
report
The Earnings field is not completely visible
because the page isnt wide enough to display it.

2 Choose File, Page Setup To open the Page Setup dialog box.
3 Under Orientation, select
Landscape
If a printer driver is not
installed, this option will
not be available.
4 Click OK To close the dialog box and apply the new
setting.
Tell student they may
have to scroll to the right
to see the field.
5 Observe the report The Earnings field is now visible.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 119

Report titles
Explanation A finished report should always include a report title that defines its purpose. To add a
report title, click the Design tab. Drag the Report Title field from the Field Explorer to
the Page Header section of the report.
Refresh report data
After you make changes in a report, its a good idea to refresh the report data. Some
changes made to a report can be viewed only after you refresh the data, which will
incorporate modifications made in Design view and will retrieve updated information
available from the source database. To refresh report data, click the Refresh button on
the Navigation Tools toolbar, or choose Report, Refresh Report Data.


Exhibit 1-7: A portion of the report showing the report title
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
120 Crystal Reports 11: Basic

Do it! B-4: Adding a report title
Heres how Heres why

1 Switch to Design view Click the Design tab.

On the right-hand side of the
window, position the pointer as
shown

(Or choose View, Field Explorer.) To unhide the
Field Explorer.

2 In the Field Explorer, under
Special Fields, drag Report
Title to the Report Header
section of the report


3 Choose File, Summary Info To open the Document Properties dialog box.
By default, the Summary tab is active.

In the Title box, enter Employee
Earnings


Click OK To close the Document Properties dialog box.
Tell students that
they can also press F5.
4 On the Navigation Tools toolbar,
click
Or choose Report, Refresh Report Data. To open
the Refresh Report Data dialog box.

Click OK To close the Refresh Report dialog box and
refresh the report data.

Click in the white space to the left
of the report title
To deselect the field.
Tell students that the
screen might look different
depending on where they
have placed the Report
Title.
5 Observe the report The report title appears at the top of the report,
as shown in Exhibit 1-7.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 121

Viewing reports
Explanation Depending on whether you want to focus on the overall layout of your report, or on the
details, you can change your view by zooming out or in. You can also navigate quickly
through the pages of a report by using the tools in the Navigation Tools toolbar.
To change the view of a report, click the Zoom tool on the Standard toolbar and select
the desired magnification level from the drop-down list. Alternatively, you can choose
View, Zoom, and select the zoom option you want.
To navigate in a report, you can click one of the Show buttons in the Navigation Tools
toolbar in the Crystal Reports window, or on the Navigation Tools toolbar in the
Preview tab. You can also choose Edit, Go to Page to open the Go to Page dialog box.
Here, you can enter the number of the page you want to view, or choose the next or
previous pages.
Do it! B-5: Viewing a report
Heres how Heres why
Tell students that they can
also use the Zoom
command by choosing
View, Zoom.
1 On the Standard toolbar, click as
shown

To open the list of magnification levels.

2 From the list, select Whole
Page
To view the entire page of the report in Preview
mode.

Observe the report The entire first page of the report is now visible
on the screen.

3 Change the magnification level
back to 100%
Click the Zoom tool, and select 100% from the
list.

4 On the Navigation Tools toolbar,
click
The Show Next Page button. To advance to the
next page of the report.

Click
(On the Navigation Tools toolbar.) To advance
to the last page of the report.

5 Click
To return to the first page of the report.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
122 Crystal Reports 11: Basic

Saving reports
Explanation After you create a report, you can save it. You can use the Save and Save As commands
on the File menu to save a report.


To save a report for the first time:
1 Choose File, Save, or File, Save As to open the Save As dialog box.
2 From the Save in list, select the folder in which you want to save the report.
3 In the File name box, enter the name of the report, if necessary.
4 Click Save.
When you make changes to an existing report, you need to update it. You can update a
report by choosing File, Save or by clicking the Save button on the Standard toolbar. If
you want to save an existing report with a new name or in a new location, you would
use the Save As command.
The Save Data with Report command
In addition to the Save and Save As commands, you can use the Save Data with Report
command to save both the design of the report and the data used in it. When you use
this command, subsequent changes to the data source will not be reflected automatically
in the report. Instead, you must manually refresh the data. This option also uses more
disk space.
When the Save Data with Report command is on, a check mark appears next to it on the
File menu. It is on by default, and if you turn off the command, Crystal Reports saves
only the design specifications. When it is turned off, the program will retrieve the data
from the data source each time the report is run so that any changes made to the data are
reflected automatically in the report.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 123

Do it! B-6: Saving a report
Heres how Heres why

1 Choose File To display the File menu.

Observe the Save Data with
Report command

It is checked, meaning that when you save the
report, Crystal Reports will save the data used to
preview the report as well.

Click Save Data with Report To turn off the Save Data with Report option.

2 Choose File, Save To open the Save As dialog box.

3 In the Save in list, verify that the
current unit folder is selected
Youll save the file in this folder.

In the File name box, edit the
name to read My employee
earnings


In the Save as type list, verify that
Crystal Reports is selected


Click Save

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
124 Crystal Reports 11: Basic

Topic C: Modifying report layout
Explanation After you have created the basic report structure, you might want to alter the appearance
of the report by rearranging, resizing, or realigning certain fields.
Field size
The width of an object frame is the field width. Initially it is set to the width needed to
display the maximum number of characters in the field using the font selected for that
field. If you later change the font size or style, the data display might be truncated. You
need to change the width of the object frame to display the field data fully. You can
change this width by resizing the field. To change a fields size, select it and drag a
sizing handle.
The Make Same Size command
To ensure uniformity of appearance in your report, you may wish to make certain fields
or objects the same size. You can use the Make Same Size command to easily adjust the
size of a field to be consistent with other fields. To do so, select the field whose size you
wish to copy, choose Format, Make Same Size, and select one of the size options on the
submenu.
Do it! C-1: Sizing fields
Heres how Heres why

1 Choose File, Summary Info Youll change the report title to make it longer.

On the Summary tab, in the Title
box, edit the title to read
Employee Earnings by
Department


Click OK To close the Document Properties dialog box.

Observe the report The report title is cut off.

2 Switch to Design view

In the Report Header section,
select the Report Title field
Click to select.
Encourage students to
experiment with the size
of the field.
Position the mouse pointer on the
right-hand sizing handle of the
field, and drag to the right as
shown

(To about the 9-inch mark on the ruler.) To
increase the size of the field.

Deselect the field Click in a white area of the report.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 125



3 Preview the report The entire report title is now visible.

4 Switch to Design view
Ensure that
students select the field
and not the field heading.
In the Details section, resize the
First_name field as shown

To make better use of the space available. Note
that the field heading automatically resizes
along with the field.

5 Select the Last_name field Youll make this the same size as the
First_name field

Press c and click on the
First_name field
So that both fields are selected.

Choose Format, Make Same
Size, Width
To resize the Last_name field to the same size as
the First_name field. This frees up more space in
the layout and will make it easier to rearrange
fields later.

Deselect the fields

6 On the Standard toolbar,
click
To update the report.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
126 Crystal Reports 11: Basic

Field arrangement
Explanation You might want to arrange fields differently to convey information better. Or, you
might want to insert or delete extra white space between columns for better display and
balance.
To move a field, select it and then drag the object frame to its new location.
Do it! C-2: Arranging a field
Heres how Heres why

1 Activate the Design tab (If necessary.) Youll change the order of the
fields in the report.
2 In the Details section, select the
First_name field

Ensure that
students select the field,
and not the field heading.
Drag the field to the right of the
Last_name field, as shown
In the Details section. Notice that the field
heading moves with the field.



3 Deselect the field

Preview the report There is excessive white space between the
Employee_code and Last_name fields.

4 Switch to Design view

Drag the Last_name field to the
left, as shown
To move it closer to the Employee_code field.



5 Drag the First_name, Region, and
Department fields to the left
To decrease the amount of white space between
the fields.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 127


6 In the Page Header section, select
the heading for the Earnings field

In this case,
students must select the
field heading, and not the
field itself.
Drag the field heading to the left To move it closer to the Department field
heading. The field itself does not move when
only the heading is selected.
Deselect all fields and preview the
report
The data in the Earnings field is no longer under
the Earnings field heading.
Tell students that the
misalignment of field and
field heading will be fixed
in the next activity.
7 Update the report Click the Save button on the Standard toolbar, or
choose File, Save.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
128 Crystal Reports 11: Basic

Field alignment
Explanation To align two or more fields, first select all the fields that you want to align. Choose
Format, Align and then select the alignment command you want. The selected fields
will be aligned with the last object you selected. To select multiple fields, press and
hold the Ctrl key while selecting the fields.
The following table describes the options on the Align submenu.

Option Description

Tops Aligns the tops of all selected objects with the last object selected

Middles Aligns the middles of all selected objects with the last object selected

Bottoms Aligns the bottoms of all selected objects with the last object selected

Baseline Aligns the baselines of all selected objects with the baseline of the last
object selected

Lefts Aligns the left sides of all selected objects with the last object selected

Centers Aligns the centers of all selected objects with the last object selected

Rights Aligns the right sides of all selected objects with the last object selected

To Grid Aligns the selected objects with the grid

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 129

Do it! C-3: Aligning fields
Heres how Heres why

1 Switch to Design view Youll align the report fields.

2 Increase the size of the Details
section, as shown
Tell students that
after they have selected
the field, they can also
use arrow keys to move it.
3 Select the Earnings field and drag
it down slightly, as shown


Deselect the field Youll align the other fields to the Earnings
field.

4 Select the first field in the Details
section
The first field is Employee_Code.
Remind students that the
alignment is to the last
object selected
5 Press c and select the
remaining fields in order, ending
with the Earnings field


6 Choose Format, Align,
Middles
To align the selected fields to the Earnings field
by vertical middles.

7 In the Details section, select the
Earnings field
Youll align the field with the heading.

Press c and select the
Earnings field heading


8 Choose Format, Align, Rights To align the field and its heading by the right
sides of the objects.

Deselect the objects

9 Preview the report

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
130 Crystal Reports 11: Basic

Modify text objects
Explanation


You can easily modify the text that Crystal Reports places in the Page Header section
when you insert database fields. To change the text displayed by a text object, double-
click the object, modify the text, and then deselect the object.
You can also format text objects in Crystal Reports the way you would format text in a
word processing program such as Microsoft Word.


Exhibit 1-8: A portion of the report shown with the text objects modified
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 131

Do it! C-4: Modifying a text object
Heres how Heres why

1 Switch to Design view

2 Observe the Page Header section The text items in the section appeared by default
when the database fields were added to the
Details section. They display the exact names of
the fields, but you can change them to anything
you want.

3 In the Page Header section,
double-click Employee_code
To place the text object in edit mode. The object
now has a marquee around it, and has a flashing
insertion point inside it.

Edit the object to read
Employee code
Replace the underscore with a space.

Deselect the object

4 In the Page Header section, edit
the Last_name heading to read
Last
Double-click it, edit it, and deselect it.

5 Edit the First_Name heading to
read First


Deselect all fields
6 Preview the report It should look like Exhibit 1-8.
7 Update and close the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
132 Crystal Reports 11: Basic

Topic D: The Help feature
Explanation While working in Crystal Reports, you might need more information about its tools and
features. The online Help feature includes directions to perform such common tasks as
placing fields, formatting reports, creating formulas, and sorting records. It also contains
information on command references, data sources, functions and operators. Sample
reports included with several Help topics help you to understand the related concepts.
Crystal Reports Help
To start the Help system, choose Help, Crystal Reports Help. The Crystal Reports
Online Help window has four tabs, each of which is described in the following table.

Tab What it displays
Contents Expandable topic categories; you click a topic to display it in the right pane.

Index All topics in alphabetical order.

Search All topics containing the keyword(s) you specify.

Favorites A list of frequently searched topics.

Do it! D-1: Using the Help feature
Heres how Heres why

1 Choose Help, Crystal
Reports Help
To open the Crystal Reports Online Help
window, which contains Contents, Index,
Search, and Favorites tabs. The Contents tab is
active.

Maximize the window If necessary.

2 Observe the left pane

It displays a list of Help categories.

3 Double-click Quick Start To expand the topics in this category and
display the topic in the right pane.

Expand the Learning how to
use Crystal Reports category
(Double-click it or click the plus sign.) There
can be several levels of categories below a
category.

4 Activate the Index tab This tab lists all the Help topics alphabetically.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 133



5 Type Date function In the Type in the keyword to find box.

Observe the list The Date function index entry is selected.

Click Display (At the bottom of the index.) To display
information on the Date function.

The Search tab
You can use the Search tab to find Help topics that pertain to a keyword you specify.
Heres how:

1 In the search box, type a keyword.
2 Click List Topics to display a list of topics that contain the keyword.
3 Select a topic and click Display.
Do it! D-2: Using the Search tab
Heres how Heres why

1 Activate the Search tab It permits you to find Help topics that pertain to
a keyword you specify.

2 Type Report header

As soon as you type anything in the Type in the
word(s) to search for box, the List Topics button
becomes active.
Tell students that they can
select any topic displayed
in the list.
Click List Topics To display a list of Help topics that contain the
keywords Report header. The topic Report
Options dialog box is selected.
3 From the list, select Live
headers

Tell students that
they can also double-click
the Help topic to display it.
Click Display To display the Help topic Live headers in the
right-hand pane.

Observe the Help topic The keywords you searched for are highlighted.

4 Click
To close the Crystal Reports Online Help
window.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
134 Crystal Reports 11: Basic

Unit summary: Getting started
Topic A In this topic, you learned about the main features of Crystal Reports. You learned how
to open a report, and you examined the elements of the Crystal Reports window. You
also looked at the Design tab and learned how to modify the size of the report section.
Topic B In this topic, you learned how to create a simple report. You learned to use the
Database Expert to select a data source, and the Field Explorer to add fields to the
report. You also learned how to change the page orientation of a report and to add a
report title. Next, you learned how to view and navigate within a report. You learned
that you can save a report by using the Save or Save As commands. Finally, you
learned about the Save Data with Report command.
Topic C In this topic, you learned how to make simple modifications to a report. Specifically,
you learned how to size, move, and align fields, as well as how to modify a text object.
Topic D In this topic, you learned how to use the Crystal Reports Online Help. You learned that
the Contents tab provides categorized Help topics, while the Index tab lists all topics
in alphabetical order. Finally, you learned how to search for topics that contain
keywords you specify.
Independent practice activity
In this activity, youll practice creating a new report and modifying its layout and
objects. Youll also practice using the Help feature.
1 Create a new, blank report document. To connect to the proper data source, browse
for Retailerdatabase (in the current unit folder) in the Access/Excel (DAO) dialog
box.
2 In the Database Expert dialog box, add the Retailers table from Retailerdatabase.
3 Change the page orientation to Landscape.
4 Place all the fields from the Retailers table in the report.
5 Save the report as My retailers in the current unit folder.
6 Add a report title and name it Retailer Information. Use Summary Info to name
the title.
7 Add a page number field to the Page Footer section of the report.
8 Change the size of the Retailer_name field to accommodate the full name of all the
retailers. Resize the other fields as necessary.
9 Rename the Retailer_Code field to Code, and the Retailer_Name field to Name.
10 Increase the size of the Details section slightly.
11 Preview the report. It should look similar to Exhibit 1-9.
12 Update and close the report.
13 Use Crystal Report Help to find information about Report footers.
14 Close Crystal Report Help.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Getting started 135




Exhibit 1-9: The new report should look like this after step 10 of the Independent
Practice Activity
Review questions
1 Name two possible data sources for a Crystal Reports report.
Microsoft Access
Microsoft SQL Server
DBAse
FoxPro
2 What is the difference between the Design tab and the Preview tab?
You create reports using the Design tab, placing report fields where you want them and
formatting them according to your own requirements. The Design tab doesnt contain the actual
data being reported. The Preview tab is used to view the report as it will look when printed, and
includes the data being reported.
3 What function does the Database Expert serve when creating a report?
You use the Database Expert to select a data source for the report.
4 What is the Field Explorer?
The Field Explorer displays a tree view of the types of fields you can use in a report.
5 What is a text object used for?
Text objects are used to insert labels, titles, and summaries.
6 What is the function of the Save Data with Report command?
A To save both the design of the report as well as the data used in it
B To refresh the report data
C To allow you to preview the report
D To allow you to format the database fields in the report
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
136 Crystal Reports 11: Basic

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
21

Un i t 2
Formatting
Unit time: 90 minutes
Complete this unit, and youll know how to:
A Apply formats that appear under all
conditions by using absolute formatting.
B Apply formats that depend on field values
by using conditional formatting.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
22 Crystal Reports 11: Basic

Topic A: Absolute formatting
Explanation Formatting means changing a reports appearance by changing the layout of the report
or the appearance of the objects in the report. For example, you can change a text
objects font, or add lines, boxes, and colors to emphasize important data. Formatting
that applies under any condition is called absolute formatting.
The Format Editor dialog box
You use the tabs in the Format Editor dialog box to format fields. You use the Font tab,
shown in Exhibit 2-1, to change the font style, size, or color.
To format a field:

1 Select the field and choose Format, Format Text, or Format, Format Field to
open the Format Editor dialog box. The Common tab is active.
2 Activate the Font tab.
3 On the Font tab, make changes to the style, size, or color.
4 Click OK to apply the changes.
To format multiple fields, select all the fields and then choose Format, Format Objects.



Exhibit 2-1: The Format Editor dialog box with the Font tab active
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formatting 23

The Formatting toolbar
You can also change field formatting by using the options displayed on the Formatting
toolbar. To do so, select the field or fields you want to format, and then click the desired
option on the toolbar.


Exhibit 2-2: A portion of the report after applying the formatting
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
24 Crystal Reports 11: Basic

Do it! A-1: Formatting a field
Heres how Heres why

1 Open Employee Earnings From the current unit folder.

Save the report as My
employee earnings


2 Unhide the Field Explorer Position the mouse pointer on the Field Explorer
name.
Under Database Fields, from the
Employees table, add the
Start_Date field to the report
Tell student to add the
field to left of the Earnings
field, and then move it to
the right of the Earnings
field after the Field
Explorer auto-hides. Rename the heading for the field
to Start Date


3 Select the Report Title field In the Report Header section.
4 Choose Format, Format Field To open the Format Editor dialog box. The
Paragraph tab is active.
Activate the Font tab
Tell students that
they can also right-click
the field and choose
Format, Field from the
context menu.
5 From the Style list, select Bold To apply Bold formatting to the text.

From the Size list, select 14 To increase the font size to 14 pts.

From the Color list, select the
indicated color (Navy)

To change the text color to navy.

Click OK To close the Format Editor and apply the new
formatting.

6 In the Page Header section, select
all the field headings
(Ctrl+click each heading to select them.) Youll
apply new formatting to the headings.

On the Formatting toolbar,
click
To apply Bold formatting to the text in the
headings.

Deselect the fields
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formatting 25


7 Preview the report Choose View, Print Preview to display the
Preview tab. To see the new formatting.
8 Switch to Design view Youll make some adjustments to the fields so
that they are displayed better.
Tell students that
another way to display the
Preview tab for the first
time is to click the Refresh
button on the Navigation
Tools toolbar.
Select the Report Title field

Position the mouse pointer at the
sizing handle on the bottom edge
of the field, and drag down
slightly, as shown

To enlarge the section and the field so that the
entire title is visible.

9 In the Page Header section, widen
the Employee Code heading
Select the field and drag the right edge slightly
to the right, so that it displays fully.

Move and resize other fields as
necessary to better display the
data


10 In the Details section, apply the
Italic style to the Employee Code
field
Select the field and click the Italic button on the
Formatting toolbar.

11 In the Page Header section, select
the Earnings heading
Youll align the text.

On the Formatting toolbar,
click
To align the text to the left side of the frame.

In the Details section, left-align
the Earnings field
Select the field and click the Align Left button
on the toolbar.

12 Select the Report Title field

Click
(On the Formatting toolbar.) To align the text in
the center of the frame.

13 Deselect the field
14 Preview the report It should look similar to Exhibit 2-2. Tell students that their
report might look
somewhat different
depending on where they
placed the fields.
Update the report Choose File, Save or click the Save button on
the Standard toolbar.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
26 Crystal Reports 11: Basic

Date formats
Explanation You can choose the format in which a date will appear in your report. Crystal Reports
offers a variety of different formats, and you can also customize the format to suit your
particular needs. To change the date format, select the date field and choose Format,
Field. On the Date and Time tab of the Format Editor, select the date format you want.
Alternatively, click Customize, and create your own date format from the options
available.
Do it! A-2: Formatting a date field
Heres how Heres why

1 Observe the Start Date field (In Preview mode.) The date format is
m/d/yyyy, followed by a time stamp.

2 Switch to Design view

3 Right-click the Start Date field
and choose Format Field from
the menu
(Or choose Format, Format Field.) To open the
Format Editor. The Date and Time tab is active.

4 From the Style list, select the
indicated style


Click OK To close the Format Editor and apply the new
date format.

Deselect the field

5 Preview the report The date appears in the new format, with no
time stamp.

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formatting 27

Lines and boxes
Explanation You can add lines and boxes to emphasize important data. You can format lines and
boxes in the Format Editor dialog box by increasing or decreasing line width, adding a
shadow, or changing color.
To add a line, choose Insert, Line. The pointer changes to a pencil, and you draw where
you want the line to appear.
To add a box, choose Insert, Box. The pointer changes to a pencil, and you drag where
you want the box to appear.


Exhibit 2-3: A portion of the report after adding a line and a box
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
28 Crystal Reports 11: Basic

Do it! A-3: Adding lines and boxes
Heres how Heres why

1 Switch to Design view

Increase the size of the Page
Header section slightly
Youll add a line in this section.

2 Choose Insert, Line The pointer changes to a pencil.

3 In the Page Header section, point
as shown

Youll draw a line from here.

Drag the pencil under all the field
headings
To draw the line.

4 Verify that the line is selected Sizing handles appear on each end of the line.

Choose Format, Format Line To open the Format Editor dialog box.

Under Border, select the line
width indicated

To change the width of the line to 1.5 pt.

Click OK To close the Format Editor and apply the new
line setting.

5 Scroll left If necessary.

6 Increase the size of the Report
Header section slightly
Youll insert a box here.

Choose Insert, Box The pointer changes to a pencil.

In the Report Header section,
point to the upper left corner of
the Report Title field, as shown


Drag to create a box around the
entire Report Title field

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formatting 29



7 Verify that the box is selected

Choose Format, Format Box To open the Format Editor dialog box. The Box
tab is active.

8 Under Border, check Drop
Shadow
To add a shadow to the box.

Under Fill, check Color Youll apply a color to the box to further set it
apart from the rest of the report.

Click the down arrow to the right
of the color box
To open the color palette.

From the color palette, select
Silver, as indicated


9 Click OK To apply the changes.
Remind students to
deselect the box.
10 Preview the report A line appears beneath the field headings, and
the report title is now enclosed within a box, as
shown in Exhibit 2-3.

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
210 Crystal Reports 11: Basic

Shapes
Explanation In Crystal Reports, a shape is a box with rounded corners. You can increase or decrease
the roundness of the shape by using the Rounding tab of the Format Editor dialog box.
To add a box that has rounded corners:


1 Add a box to your report or select an existing box.
2 Right-click the box and choose Format Box to open the Format Editor dialog
box.
3 Activate the Rounding tab.
4 Enter a value in the Rounding box to give a rounded style to the box.


Exhibit 2-4: The report title shown in a rounded box
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formatting 211

Do it! A-4: Adding a shape
Heres how Heres why

1 Activate the Design tab
2 Right-click the bottom edge of the
box around the Report Title field
To display a shortcut menu.
Ensure that
students click on the box,
not the text.
Choose Format Box To open the Format Editor dialog box. The Box
tab is active.

3 Activate the Rounding tab

Edit the Rounding box to read 20 To provide 20 percent rounding to the box.
Observe that the slider also moves to indicate
the value entered.

Click OK To apply the change.

4 Deselect the box

5 Preview the report The report title appears in a rounded box, as
shown in Exhibit 2-4.

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
212 Crystal Reports 11: Basic

Using Format Painter
Explanation You can copy absolute or conditional formatting properties from one report object to
another through a single click by using Format Painter. If you apply formatting to a
target field that is not the same as your source field, only the common properties are
applied. For example, if your source field is a date field and your target field is a string
field, only the common font and border properties are changed; date properties are not
applied to the target field.

To use the Format Painter to copy and apply formatting, select a source object or field in
your report and choose Format, Format Painter. Click the target object or field to apply
the formatting. To apply the formatting to several objects, press the Alt key while
clicking target fields.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formatting 213

Do it! A-5: Using Format Painter to change font styles
Heres how Heres why

1 Activate the Design tab
2 In the Details section, select
Employee code
To select the source format. Tell students that they will
copy the format of
Employee Code and apply
it to the remaining fields
3 Choose Format, Format
Painter
The pointer turns into a paintbrush.

4 While pressing a, click the
remaining fields in the Details
section
To apply the source format to these fields.

5 Release a and click once
more in the Start Date field
To exit Format Painter.

6 Deselect the field and preview the
report
The font for all the fields is now italicized.

7 Switch to Design view Youll remove the underlines from the field
headings.

8 In the Page Header section, select
the Employee Code field heading


Click
(On the Formatting toolbar.) To remove the
underline from the heading.

9 Using Format Painter, remove the
underlines from the remaining
field headings
With the Employee Code heading selected,
choose Format, Format Painter. Alt+click the
remaining field headings to remove the
underline.

Exit Format Painter Release Alt and click the Start Date heading
again.

10 Deselect all fields and preview the
report
The underlines have been removed from all field
headings.

11 Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
214 Crystal Reports 11: Basic

Topic B: Introducing conditional formatting
Explanation Formatting that is applied to data only under specific conditions is called conditional
formatting. For example, when payment is due on an order, you can highlight it in
yellow. To specify conditions, you can create formulas by using either the Formula
Editor or the Highlighting Expert.
The Highlighting Expert
You use the Highlighting Expert to apply conditional formatting to all types of fields
without having to write any formulas. The Highlighting Expert creates formulas that
say, If the condition is true, then apply the specified formatting. The Formula
Workshop, however, offers more flexibility in the use of conditional formatting as
compared to the Highlighting Expert.
The Highlighting Expert dialog box is divided into two sections: the Item editor section
and the Item list section. You specify the formula in the Item editor section, and the
Item list section displays it.
To use the Highlighting Expert to create a conditional format:


1 Select a field and choose Format, Highlighting Expert to open the Highlighting
Expert dialog box, as shown in Exhibit 2-5.
2 Click New.
3 Under Item editor, from the Value of list, select the field.
4 From the second list in the Item editor section, select a comparison.
5 From the third list in the Item editor section, select a value.
6 Select formats from the Font color, Background, and Border lists.
7 Click OK to apply conditional formatting.



Exhibit 2-5: The Highlighting Expert dialog box
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formatting 215




Exhibit 2-6: Conditional formatting used to highlight specific values
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
216 Crystal Reports 11: Basic

Do it! B-1: Using the Highlighting Expert
Heres how Heres why
1 Switch to Design view
Tell students that
they will highlight earnings
that equal $85,000 or
greater.
2 In the Details section, select
Earnings
Youll create a conditional format for this field.
Choose Format, Highlighting
Expert
To open the Highlighting Expert dialog box, as
shown in Exhibit 2-5.
Click New
Tell students that
they can also right-click
the field and choose
Highlighting Expert from
the context menu.
3 Observe that in the Value of list,
this field is selected
The Earnings field.

From the second list, select is
greater than or equal to
To specify an operator for the formula.

From the third list, select
$85,000

To complete the conditional formula for the
Earnings field.

4 Observe the Item list section

The formula is specified.

Under Item editor, from the
Background list, select Yellow
(You might need to scroll down in the list.) To
highlight in yellow those values in the Earnings
field which meet the specified condition.

Click OK To close the Highlighting Expert dialog box.

5 Deselect the field and preview the
report
All earnings greater than or equal to $85,000 are
now highlighted, as shown in Exhibit 2-6.

6 Update and close the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formatting 217

Unit summary: Formatting
Topic A In this topic, you learned about absolute formatting. You learned how to format a
report by using the Format Editor. You learned that you can format a report by
changing the style, size, and color of fonts. You also learned how to add lines, boxes,
and shapes. Finally, you learned how to use the Format Painter to copy and apply
formats from one field to another.
Topic B In this topic, you were introduced to conditional formatting. You learned how to use
the Highlighting Expert to change formatting based on a specified condition.
Independent practice activity
In this activity, youll practice applying absolute formatting of field headings and fields.
Youll also practice using the Highlighting Expert to format a field conditionally.
1 Open Retailer Information.
2 Save the report as My retailer information.
3 In the Page Header section, change the font style of all the field headings to bold.
Resize the headings as necessary to accommodate the new style.
4 In the Report Header section, change style of the Report Title text to bold, the font
size to 14, and the color to red.
5 Center-align the Report Title field. Insert a box around the report title, and apply a
1.5 pt line width. Apply the Drop Shadow effect and a fill color of silver. Adjust the
size of the field as necessary to accommodate the new formatting.
6 Add more white space to the Page Header section and draw a line under all the field
headings. Apply a width of 1.5 pt to the line.
7 Update and preview the report. It should look similar to Exhibit 2-7.
8 Activate the Design tab. Change the font style to bold and the font color to green for
the retailers from CA. (Hint: Select the State field and choose Format, Highlighting
Expert.)
9 Change the background color to silver for retailers from San Diego.
10 Preview the report. It should look like Exhibit 2-8.
11 Update and close the report.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
218 Crystal Reports 11: Basic



Exhibit 2-7: A portion of My retailer information after step 7 of the Independent
Practice Activity

Exhibit 2-8: A portion of My retailer information after step10 of the Independent
Practice Activity
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formatting 219

Review questions
1 What is absolute formatting?
Formatting that applies under any condition
2 How do you format a field in a report?
Select the field and choose Format, Format Field, or right-click the field and choose Format Field
in the context menu. Either command opens the Format Editor dialog box.
3 In Crystal Reports, what is a shape?
A box with rounded corners
4 Describe the Format Painter.
The Format Painter is a tool that helps you apply the same formatting from a source field to a
target field.
5 What is conditional formatting?
A Formatting that stays the same in all conditions.
B Formatting that can be changed using the Field Explorer.
C Formatting that is applied only under specified conditions.
D Formatting that can be changed using the Format Painter.
6 What is the purpose of the Highlighting Expert?
The Highlighting Expert allows you to apply conditional formatting without having to write
formulas.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
220 Crystal Reports 11: Basic

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
31

Un i t 3
Sorting and selecting records
Unit time: 75 minutes
Complete this unit, and youll know how to:
A Sort records in ascending or descending
order.
B Display only the records you want by
creating record selection formulas using
single or multiple criteria.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
32 Crystal Reports 11: Basic

Topic A: Sorting records
Explanation When you create a report, the data in the report appears in the order in which it was
entered in the database. Sorting means organizing data in a specific order. For example,
you might want to arrange a product list in descending order by sales.
The Record Sort Expert command
You use the Sort Records command to sort records. To do so, you need to specify the
sort field and sort direction. The sort field is the field by which you want to sort, and the
sort direction is the order in which to sort the records, ascending or descending.
To sort records:

1 Open a report.
2 Choose Report, Record Sort Expert to open the Record Sort Order dialog box, as
shown in Exhibit 3-1.
3 Under Report Fields, from the list, select the field by which you want to sort the
records.
4 Add the field to the Sort Fields list.
5 Under Sort Direction, select either ascending or descending order.


Exhibit 3-1: The Record Sort Expert dialog box
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Sorting and selecting records 33

Do it! A-1: Sorting records in ascending order
Heres how Heres why

1 Open Employee Earnings (From the current unit folder.) The records in
this report are sorted by employee code. Youll
sort them by region.

2 Save the report as
My employee earnings


3 Choose Report, Record Sort
Expert
To open the Record Sort Expert dialog box.

Under Available Fields, from the
Report Fields list, select
Employees.Region


Click
To add Employees.Region to the Sort Fields list.

4 Under Sort Direction, verify that
Ascending is selected
(The dialog box should look like Exhibit 3-1.)
By default, records are sorted in ascending
order.

Click OK To close the Record Sort Expert dialog box.
5 Preview the report The records are sorted by region.
6 Activate the Design tab Youll further sort the records by department.
Tell students to navigate
through the pages of the
report to see how the
records have been sorted.
7 On the Expert Tools toolbar,
click
Or choose Report, Record Sort Expert.

Add Employees.Department
to the Sort Fields list
Select the field and click the arrow button to add
it to the list.

Under Sort Direction, select
Descending


Click OK To close the Record Sort Expert.

8 Preview the report The records are now sorted in ascending order
by region, and descending order by department.

9 Change the sort direction for the
Employees.Department field to
Ascending
Open the Record Sort Expert, select the
Employees.Department field, and choose
Ascending.

10 Preview and update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
34 Crystal Reports 11: Basic

Topic B: Selecting records
Explanation When you first create a report, it contains all the records from the table on which it is
based. However, you might want a report that includes only some of a tables records.
For example, you might want to see a sales report for a specific product. To accomplish
this, you can create a selection formula to specify conditions for choosing records for
the report.
A condition uses a comparison operator, such as =, <>, <, or >, and an expression. An
expression specifies the value for a comparison. It can contain fields, numbers,
characters, or dates. When you use a character as an expression, you must enclose it in
quotes.
The Select Expert command
The Select Expert command automatically generates a selection formula based on a
condition you specify. If you select a field before choosing Report, Select Expert, the
Select Expert dialog box opens. However, if you dont select a field before choosing the
command, the Choose Field dialog box opens.
There are two types of selection formulas:
Record Selection formulas, which are used to select specific records
Group Selection formulas, which are used to select specific groups of records
You can specify single or multiple conditions for a selection formula. For each
condition you specify, a tab with the field name is added to the Select Expert dialog
box, as shown in Exhibit 3-2. After you create a selection formula, Crystal Reports will
prompt you to refresh data from the database or saved data in the report.


Exhibit 3-2: The Select Expert dialog box
Single-criterion formulas
A single-criterion formula contains only one condition. For example, you might want to
see the records for all employees in the South region. In this example, you would set a
condition in which the value in the Region field would equal South.
To select records based on a single condition:

1 Choose Report, Select Expert to open the Choose Field dialog box.
2 From the list, select the field on which you want to base your condition.
3 Click OK to open the Select Expert dialog box.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Sorting and selecting records 35

4 From the list, choose a criterion for selecting records. A second list that contains
the data stored in the selected field will appear.
5 From the second list, select a value.
6 Click OK to close the Select Expert dialog box. A message box prompting you
to refresh data from the database or saved data will appear.
7 Click Use Saved Data.
Do it! B-1: Selecting records based on a single criterion
Heres how Heres why
1 Verify that no fields are selected
2 Choose Report, Select Expert To open the Choose Field dialog box.
Tell students that
they will display records of
the employees in the
Administration department
only.
From the Report Fields list, select
Employees.Department
Youll create a record selection formula for the
Department field.

Click OK To open the Select Expert dialog box. The
Employees.Department tab is active.

3 From the drop-down list, select is
equal to
A second list containing the data stored in the
Department field appears.

From the second list, select
Administration
(The dialog box should look like Exhibit 3-2.)
To select records only for employees in the
Administration department.

4 Click Show Formula

The Select Expert dialog box expands, showing
the formula to select records for employees in
the Administration department.

Click Hide Formula

5 Click OK A message box appears, prompting you to
refresh the data either from the database or from
the saved data in the report.

Click Use Saved Data To use records from data saved in the report.

6 Preview the report The report contains records only for employees
in the Administration department. Notice that
the records are still sorted by region.

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
36 Crystal Reports 11: Basic

Deleting selection formulas
Explanation


After creating a selection formula, you might decide you want the report to include all
the records from the table again. In that case, youll need to delete the selection formula.
To do this:
1 Choose Report, Select Expert to open the Select Expert dialog box.
2 Activate the tab for which you want to delete the formula, and then click Delete.
3 Click OK to close the dialog box. Youll be prompted to refresh the data.
4 Click Use Saved Data.
Do it! B-2: Deleting a single-criterion selection formula
Heres how Heres why

1 On the Expert Tools toolbar,
click
Or choose Report, Select Expert. To open the
Choose Field dialog box.

2 Click Delete To delete the record selection formula.

Click OK A message box appears.

Click Use Saved Data

3 Observe the report The report once again includes records for all
the employees, and the records are still sorted by
region.

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Sorting and selecting records 37

Multiple-criteria formulas
Explanation A multiple-criteria formula contains more than one condition. For example, you might
want records of all retailers in the East region who have sales greater than $15,000. To
get that result, you would need to create a formula that meets the following conditions:
The value in the Region field is equal to East.
The value in the Total Sales field is greater than $15,000.
In a multiple-criteria formula, the conditions are joined by operators, such as and or
or. You use the and operator when you want records to meet all the conditions; you
use the or operator when you want records to meet any one or more of the specified
conditions.
To select records based on multiple criteria:


1 Choose Report, Select Expert to open the Choose Field dialog box.
2 Select the field on which you want to base your condition.
3 Specify the criteria by using the Select Expert dialog box.
4 Click New to open the Choose Field dialog box.
5 Select a second field and close the Choose Field dialog box to return to the
Select Expert dialog box.
6 Specify the condition for the second field. You can view the formula by clicking
the Show Formula button.
7 Close the dialog box and refresh the report data.


Exhibit 3-3: The records selected by the multiple-criteria formula
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
38 Crystal Reports 11: Basic

Do it! B-3: Selecting records based on multiple criteria
Heres how Heres why

1 Open the Choose Field dialog box Choose Report, Select Expert, or click the Select
Expert button on the Expert Tools toolbar.
2 From the list, select
Employees.Department
The first criterion will be based on department.
Click OK To open the Select Expert dialog box with the
Employees.Department tab active.
Tell students that
due to a change in policy
for the employees in the
South region, HR needs a
list of employees in
departments other than
Administration from that
region.
3 From the list, select is not
equal to


From the second list, select
Administration
To select the records of employees who do not
work in the Administration department.

4 Click New To open the Choose Field dialog box.

Select Employees.Region The second criterion will be based on region.

Click OK To return to the Select Expert dialog box with
the new Employees.Region tab active.

5 From the list, select is equal to

From the second list, select
South
To select the records of employees who work in
the South region.

6 Click Show Formula

The formula contains both conditions joined by
the and operator.

Click Hide Formula

7 Click OK A message box appears.

Click Use Saved Data The report now contains records for South
region employees who work in departments
other than Administration, as shown in Exhibit
3-3.

8 Open the Select Expert dialog box
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Sorting and selecting records 39



9 Click Show Formula Youll change the operator in the formula so that
additional records are selected.
In the formula, edit and to read
or
Tell students that they can
edit the formula right in
the formula pane.
Click OK To select all records where the region is South
or the department is other than Administration.

Click Use Saved Data To refresh the report.

10 Observe the report Additional records based on the new criteria
have been selected.

11 Change the formula operator back
to and
Open the Select Expert dialog box, click Show
Formula, and edit the formula.

Update the report

Deleting selection criteria in a multiple-criteria formula
Explanation To delete a criterion from a multiple-criteria formula:
1 Choose Report, Select Expert to open the Select Expert dialog box.
2 Activate the tab for which you want to delete the criterion, and then click Delete.
3 Click OK to close the dialog box. Youll be prompted to refresh data.
4 Click Use Saved Data.
Do it! B-4: Deleting a criterion in a multiple-criteria formula
Heres how Heres why

1 Open the Select Expert Youll delete one of the criteria in the formula.

2 Activate the Employees.Region
tab
To delete the region = South criterion.

3 Click Delete To delete only the selection criterion of the
formula based on region.

4 Click OK A message box appears.

Click Use Saved Data The report now includes records for employees
from all regions not belonging to the
Administration department.

5 Update and close the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
310 Crystal Reports 11: Basic

Unit summary: Sorting and selecting records
Topic A In this topic, you put records in the order you want by using the Record Sort Expert
command. You also learned that data can be sorted in ascending or descending order.
Topic B In this topic, you used the Select Expert command to include only certain records or
groups in a report. You also filtered records by creating record selection formulas with
single or multiple criteria.
Independent practice activity
In this activity, youll practice sorting records by a particular field and sort order. Youll
also practice using the Select Expert to select records based on specific criteria.
1 Open Retailer Information in the current unit folder.
2 Save the report as My retailer information.
3 Sort records by Retailers.State and then Retailers.City, in ascending order.
4 Observe the report.
5 Change the sort direction for Retailers.City to descending, and preview the report.
Compare your report to Exhibit 3-4.
6 Using the Select Expert, select records for retailers from Illinois. Refresh the report.
7 Modify the selection criteria to include both Illinois and Texas retailers. (Hint: In
the Select Expert, change the condition to is one of, and choose IL and TX from the
list.) The report should look like Exhibit 3-5.
8 Update and close the report.

Exhibit 3-4: A portion of the report as it appears after step 5 of the Independent
Practice Activity
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Sorting and selecting records 311



Exhibit 3-5: A portion of the report after step 7 of the Independent Practice Activity
Review questions
1 Describe the function of the Record Sort Expert.
The Record Sort Expert helps you sort data by field and by sort direction.
2 Name two comparison operators that could be used in a selection formula.
Greater than (>)
Less than (<)
Equal to (=)
Not equal to (<>)
3 What is the Select Expert used for?
A To create a conditional formatting formula.
B To create a selection formula.
C To compare values in one field with values in another.
D To set the sort direction of records.
4 What is a single-criterion selection formula?
A formula that contains only one condition
5 What is the purpose of the and operator in a multiple-criteria selection formula?
To return records that meet all of the specified criteria in the formula
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
312 Crystal Reports 11: Basic

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
41

Un i t 4
Grouping and summarizing
Unit time: 120 minutes
Complete this unit, and youll know how to:
A Display related records together by
creating and modifying groups.
B Insert subtotals and grand totals, and put
grouped records in order by summary
values.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
42 Crystal Reports 11: Basic

Topic A: Groups
Explanation Grouping means presenting sorted data in meaningful groups. For example, you might
want to generate a sales report in which orders for a specific product appear together. In
this case, you could group the records by product code or product name. You can group
records based on a single field or on more than one field.
You can sort grouped records in ascending, descending, original, and specified order.
Original order is the order in which the records are stored in the data source. Specified
order places records into custom groups that you specify.
Creating groups
To create a group:

1 Choose Insert, Group to open the Insert Group dialog box.
2 From the first list, select the field by which you want to group the records.
3 From the second list, select the order.
4 Click OK to close the dialog box and group the records.
Group headers and footers
When you create a group, Crystal Reports automatically adds Group Header and Group
Footer sections, as shown in Exhibit 4-1. The Group Header section contains the name
or header for each set of records in the group. For example, if you grouped records
based on product name, the group header for each group of records would display the
product name. The Group Footer section can contain subtotal or summary values for
each group.

Exhibit 4-1: A grouped report in Design view
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Grouping and summarizing 43

The Group Tree view
A group tree is simply an outline of the report that displays the hierarchy of groups and
subgroups, as shown in Exhibit 4-2. The Group Tree view is useful for quick navigation
of your report, and also for drilling down to the details of a particular group.
You can show or hide the Group Tree view by clicking the Toggle Group Tree button
on the Standard toolbar, or by choosing View, Group Tree.


Exhibit 4-2: A portion of the report showing the Group Tree view on the Preview tab
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
44 Crystal Reports 11: Basic

Do it! A-1: Creating a group
Heres how Heres why
1 Open Employee Earnings In the current unit folder Tell students that they will
group records of
employees by region.
Save the report as My
employee earnings


2 Choose Insert, Group To open the Insert Group dialog box. Youll
group the employees by region.

In the first box, click the drop-
down arrow
To display a list of fields by which to sort and
group.

Select the indicated field

Notice that the order will be ascending.

Click OK To group the records by Employees.Region.

3 Deselect the field
Observe the Design tab Crystal Reports automatically created the Group
Header #1 and Group Footer #1 sections, as
shown in Exhibit 4-1.
Tell students that they can
move the field headings
from the Page Header to
the Group Header section
if they wish.
4 Refresh the report data To display the Preview tab.

Observe the left pane of the
Preview tab
The Group Tree view displays the groups
created, as shown in Exhibit 4-2.

5 In the group tree, select South To navigate directly to that portion of the report
that groups records by the South region
6 In the report, double-click the
South heading
To drill down to the details of this group in the
report.
Tell students that
they can also right-click
the group in the group tree
and select Drill Down from
the menu.
Observe the report

A new tab opens, displaying only records from
the South region.

7 On the South tab, click
To close the drill-down tab.

8 Update the report P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Grouping and summarizing 45

Modifying groups
Explanation If you need to, you can use the Change Group command to change the field on which a
report is grouped. To do so, right-click the group header section in the report and choose
Change Group from the context menu.
Date grouping
Its often helpful to group information by date, as in the case of quarterly sales figures,
or yearly earnings. To group information by date, right-click the Group Header section
you want to change, and choose Change Group from the menu. Select the date field you
want to group by, and the sort order, and click OK.
Do it! A-2: Grouping by date fields
Heres how Heres why

1 Activate the Design tab

2 Right-click in the Group Header
#1 section
The section, not the Group #1 Name field. To
display a context menu.

3 Choose Change Group To open the Change Group dialog box. The
Common tab is active.

From the first drop-down list,
select the indicated field

Youll group the information by date.

4 Under The section will be printed,
select for each year. from the
list


Click OK To close the dialog box and apply the changes.

5 Preview the report The data is now grouped by the year each
employee started at the company.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
46 Crystal Reports 11: Basic

Grouping by a specified order
You can also use the Change Group command to change the order in which groups of
records appear. In addition to the ascending and descending sort direction options, you
can also specify a user-defined sort order. For example, you might want all the records
for a particular retailer to appear at the top of the report, or that records grouped by date
are displayed by year or month. The remaining records would then be placed together in
a single group named Others.
To display groups in a specified order:

1 Select the group you want to change the order for.
2 Open the Change Group Options dialog box.
3 Select the field you want to order the group by.
3 From the sort order list, select in specified order.
4 On the Specified Order tab, name the group, and click New.
5 Select the desired options in the Define Named Group dialog box, and click OK.
6 Click OK to close the Change Group Options dialog box and apply the new
order.
Do it! A-3: Displaying groups in a specified order
Heres how Heres why

1 Activate the Design tab

2 Open the Change Group Options
dialog box
Right-click the Group Header #1 section and
choose Change Group from the menu.

3 From the second drop-down list,
select in specified order
A new tab appears. Youll specify the group
order here.

4 In the Named Group box, type
1990-1999


Click New To open the Define Named Group dialog box.
Youll select the records for this grouping.

5 From the operator list, select is
between


In the first box, type 1/1/90

In the second box, type
12/31/99


6 Click OK To close the Define Named Group dialog box.

Click OK To close the Change Group Options dialog box
and apply the new grouping.

7 Preview the report There are now two groups in the group tree:
1990-1999, and Others.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Grouping and summarizing 47



8 Create a new group and name it
2000-2009
Use the Change Group dialog box. Activate the
Specified Order tab, type 2000-2009 in the
Named Group box, and click New. Select the is
between operator and type in the date range of
1/1/00 and 12/31/09.

9 Preview the report The new group appears in the group tree, and
the data is further organized under a new date
range.

In the group tree, double-click
Others
To navigate to that grouping in the report. Note
that it contains one record, that of an employee
whose start date does not fall into either of the
date groupings specified.

10 Update the report

Subgroups
Once youve created a group, you might wish to further sort records within that group.
For example, you might want to create a group to display quarterly sales earnings, and
then create a subgroup that breaks down the information by sales person.
To create a subgroup, choose Insert, Group, and select the field on which to create the
subgroup.
Do it! A-4: Creating a subgroup
Heres how Heres why

1 Activate the Design tab

2 Choose Insert, Group

3 From the first list, select the
Employees.Department field
To create a Department subgroup within each
decade grouping.

Click OK

4 Observe the report In Design view. A new Group Header #2 section
has been added.

5 Preview the report The information is now grouped by decade and
by department within each decade group.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
48 Crystal Reports 11: Basic

Group options
You can set group options to ensure that the data appears as you want it to. For
example, you might want the group header to appear at the top of each page in case the
records selected under that group run to multiple pages. To set group options, open the
Change Group Options dialog box, activate the Options tab, and choose the desired
settings.
Do it! A-5: Setting group options
Heres how Heres why

1 In the Preview tab, observe the
spacing between the two group
headings
You want to set the Department heading off
from the data a little further.

2 Activate the Design tab Youll increase the space between the
Department heading and the data below it.

Increase the size of the Group
Header #2 section slightly, as
shown


3 Preview the report There is more space between the second group
heading and the data, but now the Department
groups are split over some of the pages.

4 Open the Change Group Options
dialog box
(Right-click the Group Header #2 section.)
Youll specify that the Department heading
appears at the top of each page, so you can
easily identify which department an employee
belongs to.

Activate the Options tab

Check Repeat Group Header
on Each Page
To display the Department header at the top of
each page.

Click OK To close the dialog box and apply the new
setting.

5 Preview and navigate through the
report
To see that the Department heading appears at
the top of the page when the list has been run on
to two pages.

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Grouping and summarizing 49

Deleting groups
When you no longer want to display information in a grouping, you can delete the
group. To do so, right-click the header of the group you want to delete and choose
Delete Group from the context menu.
Do it! A-6: Deleting a group
Heres how Heres why

1 On the Design tab, right-click the
Group Header #2 section
Youll delete the subgroup you created.

2 From the context menu, choose
Delete Group


3 Preview the report

4 Remove the decade groups On the Design tab, right-click the Group Header
#1 section and choose Delete Group from the
menu.

5 Preview the report There are no groups.

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
410 Crystal Reports 11: Basic

Topic B: Summaries
Explanation Its helpful to present summary data as well as raw data. You can summarize data by
inserting calculated values such as sums, averages, maximums, or minimums.
Summary fields
You use the Summary command to summarize information in your report. In a grouped
report, the Summary command inserts summary fields at the end of each group, rather
than at the end of the report. In an ungrouped report, you can use the Summary
command to sort, group, and perform summary calculations in a single step.
Subtotals
A subtotal is the sum of all the values within a field in a group. For example, you could
use a subtotal to show the total sales for a particular product. In the case of an
ungrouped report, Crystal Reports will sort and group data, as well as calculate the
subtotal.
To insert subtotals:

1 Choose Insert, Summary to open the Insert Summary dialog box, as shown in
Exhibit 4-3.
2 From the Choose the field to summarize list, select the field for which you want
to calculate a subtotal.
3 From the Calculate this summary list, select the type of summary field.
4 Click the arrow under summary location.
5 Choose the appropriate group.
6 Click Insert Group to open the Insert Group dialog box.
7 From the Insert Group dialog box, select the field on which you want to group
the subtotal.
8 Click OK to close the Insert Group dialog box.
9 Click OK to close the Insert Summary dialog box and insert the subtotals.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Grouping and summarizing 411




Exhibit 4-3: The Insert Summary dialog box


Exhibit 4-4: A portion of the report showing the subtotal for the South region
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
412 Crystal Reports 11: Basic

Do it! B-1: Inserting a subtotal
Heres how Heres why
1 Activate the Design tab
Tell students that
they will show subtotals of
earnings for each region. 2 Choose Insert, Summary To open the Insert Summary dialog box. Youll
display the total earnings for each region.

From the Choose the field to
summarize list, select
Employees.Earnings
To insert a subtotal for the Employees.Earnings
field.

From the Calculate this summary
list, select Sum
To display the sum of the Employees.Earnings
field.

3 Under Summary location, click
Insert Group
To open the Insert Group dialog box.

From the first list, select
Employees.Region
To group the report data by using the
Employees.Region field.

Click OK To return to the Insert Summary dialog box.

Click OK To apply the changes and close the Insert
Summary dialog box.

4 In the Group Footer #1 section,
enlarge the summary field, as
shown


Deselect the field
Preview the report The total earnings for each region is inserted at
the end of each group, as shown Exhibit 4-4.
Tell students to navigate
through the report to see
the subtotals for each
region.
5 Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Grouping and summarizing 413

Grand totals
Explanation You can also use the Summary command to insert a calculation at the end of the report.
For example, in a monthly sales report grouped by region, you could show a grand total
of monthly sales for all regions together.
To insert a grand total:

1 Choose Insert, Summary to open the Insert Summary dialog box.
2 From the Choose the field to summarize list, select the field for which you want
to calculate the grand total.
3 From the Calculate this summary list, select the type of summary field.
4 Click OK to close the dialog box.


Exhibit 4-5: The grand total at the end of a report
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
414 Crystal Reports 11: Basic

Do it! B-2: Inserting a grand total
Heres how Heres why

1 Activate the Design tab
2 Choose Insert, Summary To open the Insert Summary dialog box.
From the Choose the field to
summarize list, select
Employees.Earnings

Make sure that no
fields are selected.
Tell students that they will
see the total earnings for
all regions.
From the Calculate this summary
list, select Sum


In the Summary location list,
verify that Grand Total (Report
Footer) is selected
To display the grand total in the Report Footer
section.

3 Click OK To close the Insert Summary dialog box.

4 Increase the size of the grand total
field
To fully display the field data.

Deselect the field

Preview the report The grand total appears at the end of the report.

5 Activate the Design tab Youll insert a field header for the grand total, to
set it off from the other summary fields.

6 Choose Insert, Text Object The pointer changes to a cross.

In the Report Footer section,
position the pointer as shown


Click the mouse

An empty text box appears.

In the box, enter Grand Total To label the grand total field.

Center-align the text, and format
the text as Bold
Select the text and click the Align Center and
the Bold buttons on the Formatting Tools
toolbar.

7 Deselect the field

Preview the report It should look like Exhibit 4-5.

8 Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Grouping and summarizing 415

The Group Sort Expert command
Explanation In a grouped report, you might want to see the groups that have the highest or lowest
summary values first. For example, you might need to find the two best-selling products
in a sales report grouped by product code.
To accomplish this, you use the Group Sort Expert command. The Group Sort Expert
dialog box is shown in Exhibit 4-6. The group sort option Top N means a number you
specify, N, of groups having the highest summary values. The group sort option Bottom
N means a number, N, of groups having the lowest summary values. Your report can
also display records from all the remaining groups, which would be placed in a single
group.
To select the top or bottom N groups:

1 Choose Report, Group Sort Expert to open the Group Sort Expert dialog box.
2 From the For this group sort list, select the option you need.
3 From the based on list, select the summary field on which you want to base your
selection.
4 In the Where N is box, enter the number of groups needed and click OK.



Exhibit 4-6: The Group Sort Expert dialog box
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
416 Crystal Reports 11: Basic

Do it! B-3: Displaying the top N of groups of records
Heres how Heres why
1 Choose Report,
Group Sort Expert
To open the Group Sort Expert dialog box.
From the For this group sort list,
select Top N
Youll sort the top two groups.
Tell students that
management wants to see
the two regions that have
the highest earnings
displayed at the top of the
report. The report should
also contain data for the
remaining regions.
In the based on list, verify that
Sum of Employees.Earnings is
selected


In the Where N is box, enter 2 To put the top two groups by total earnings at
the top of the report.

Check the Include Others,
with the name option
To display the other groups under Others.

2 Click OK To close the Group Sort Expert dialog box.
3 Observe the report It displays the top two regions, North and East,
in the order of their earnings. The other regions
are included in a third group.
Tell students to navigate
through the report. The
top two regions are also
shown in the group tree.
4 Update and close the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Grouping and summarizing 417

Unit summary: Grouping and summarizing
Topic A In this topic, you put records into meaningful groups by using the Group command.
You also learned about date grouping, and putting groups in a specified order. Finally,
you learned how to set group options, and how to delete a group.
Topic B In this topic, you inserted subtotals and grand totals in a report by using the Summary
command. You also put the groups in order by summary values by using the Group
Sort Expert.
Independent practice activity
In this activity, youll group data by a particular field. You'll also practice inserting a
subtotal and a grand total, and create a group sort for the top number of records based
on a particular field value.
1 Open Retailer Information in the current unit folder.
2 Save the report as My retailer information.
3 Group the report by the City field in ascending order.
4 Move the field headings and the line from the Page Header section to the Group
Header #1 section. Resize the section as needed.
5 Preview the report.
6 Change the report to group data by the State field.
7 Insert a subtotal field to count the number of retailers in each state. To do so, choose
Insert, Summary and select Retailers.State as the field to summarize: Calculate the
summary as Count. From the Summary location list, select Group #1:
Retailers.State-A. Click OK.
8 Create a field header for the subtotal field, and name it State Count. Adjust the size
and position of the header as needed.
9 Insert a grand total of all the retailers at the end of the report. Add a field header
called Grand Total and format it in bold.
10 Preview the report. It should look similar to Exhibit 4-7.
11 Create a group sort that shows the state with the fewest number of retailers at the
top of the report. Put the remainder of the states in Others. To do so, open the Group
Sort Expert and select Bottom N for the sort criterion. In the Where N is box, enter
1. Check Include Others, and click OK.
12 Preview the report. It should look like Exhibit 4-8.
13 Update and close the report.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
418 Crystal Reports 11: Basic



Exhibit 4-7: The last page of the report after step 9 of the Independent Practice Activity

Exhibit 4-8: The first page of the report after step 11 of the Independent Practice
Activity
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Grouping and summarizing 419

Review questions
1 Which command do you use to create grouped data in a report?
Insert, Group
2 What is a group tree?
An outline that displays the groups and subgroups in a report
3 When you use the Change Group command, you can
A Change the order by which the grouped data is displayed.
B Change the field by which the data is grouped.
C Both A and B.
D Neither A nor B.
4 Define a summary field.
A field that summarizes data by inserting calculated values such as sums, averages, maximums,
or minimums.
5 Which command do you use to create a summary field for your report?
Insert, Summary
6 If you wanted a report to show which two salespeople sold the most products in a
year, what command would you use?
The Group Sort Expert command
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
420 Crystal Reports 11: Basic

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
51

Un i t 5
Formulas and functions
Unit time: 150 minutes
Complete this unit, and youll know how to:
A Create a simple formula by using the
Formula Editor.
B Edit, rename, and delete formulas.
C Perform various calculations in formulas
using Date and Time, String, and
Mathematical functions.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
52 Crystal Reports 11: Basic

Topic A: Formulas
Explanation Sometimes youll want a report to display information other than just the records it
contains, such as the results of calculations performed on the fields. For example, in a
customer report, you might want to show the total amount of money each customer
owes on the orders theyve placed. In such cases, you need to create formulas to
calculate those values. The results of such formulas are shown in formula fields.
Formula elements

A formula is made of syntax and components. Syntax refers to the rules used to create
formulas. Components are the fields, numbers, operators, functions, and text that make
up the formula, as shown in Exhibit 5-1.
Examples of syntax include the following:
Text strings must be enclosed in quotation marks.
Arguments must be enclosed in parentheses.
In a formula, a field name is always preceded by the name of its table, and the two are
separated by a period, as shown in Exhibit 5-1.
When you create a formula, you assign it a name that you can then use in the report. In
Design view, formula fields represent formulas. The names of formula fields always
begin with an "at" (@) sign. Crystal Reports automatically adds the @ sign when you
place the formula field in the report. The Formula Field branch of Field Explorer
displays a list of all available formula fields.


Exhibit 5-1: A sample formula
Do it! A-1: Discussing formula components
Questions and answers

1 In a transaction report, your manager wants to see the total amount each retailer
owes, but the database does not contain a field with this information. How can
you include the total amount in the report without adding a new field to the
database?
By creating a formula to calculate the amount each retailer owes

2 Write a formula to calculate a tax of 5% on the total amount.
Total amount * 5 / 100

3 What are the operators used in the above formula?
* and / (multiplication and division signs)

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 53

The Formula Workshop
Explanation The Formula Workshop helps you create formulas, custom functions, and SQL
Expressions. It contains toolbars, a tree with folders, and an area for creating a formula,
as well as the Expressions Editor. The Workshop Tree contains folders that hold the
formulas, custom functions, and SQL Expressions. The toolbars contain buttons that can
be used to work with the Formula Workshop as a whole, or the Workshop Tree, or the
Expressions Editor. The Formula Workshop window is shown in Exhibit 5-2.

Toolbars
Formula text
window
Workshop
Tree

Exhibit 5-2: The Formula Workshop window
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
54 Crystal Reports 11: Basic

The Formula Editor
The Formula Editor is a major component of the Formula Workshop dialog box. You
use the Formula Editor to create and modify a formula. The Formula Editor contains
four windows and a toolbar. You can use the buttons on the toolbar for actions,
including testing the syntax of the function or formula or choosing the syntax of your
formula as Basic or Crystal syntax.
This table describes the windows in the Formula Editor.

Window Description

Report Fields Contains all the database fields and any existing formulas or groups
accessible to your report

Functions Contains categories of functions, including Math, Summary,
Financial, and Strings

Operators Contains categories of operators, including Arithmetic, Conversion,
Comparisons, and Strings

Formula text window Contains the formula you create

To create a formula:

1 Activate the Design tab and choose View, Field Explorer to open Field Explorer.
2 Select Formula Fields.
3 Click the New button on the Field Explorer toolbar to open the Formula Name
dialog box.
4 In the Name box, type the name of the formula.
5 From the Report Fields window, select the fields you need.
6 Select the functions you want from the Functions window and operators from
the Operators window.
7 Check the formula for syntax errors and fix errors, if any.
8 Save the formula and close the Formula Editor window.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 55

Do it! A-2: Creating a formula
Heres how Heres why

1 Open Employee Earnings (In the current unit folder.) Youll calculate a
salary increase of 5% for employees.

2 Save the report as
My employee earnings


3 Show the Field Explorer

Select Formula Fields

Click
(The New button is on the toolbar in the Field
Explorer dialog box.) To open the Formula
Name dialog box.

4 In the Name box, enter Salary
Increase


Click OK To open the Formula Workshop Formula
Editor Salary Increase window.
Tell students to maximize
the window, if necessary.
5 Click as shown

To expand Report Fields in the Report Fields
window.

In the Report Fields pane, double-
click Employees.Earnings
To add {Employees.Earnings} to the Formula
text window.

6 Click as shown

To expand the list of operators in the Operators
window.

In the Operators window, expand
Arithmetic
To view the list of arithmetic operators.
Double-click Multiply ( x * y ) In the Formula text window, * is added after
{Employees.Earnings}.
Point out that
students can also type
fields and operators
directly in the text window.
7 In the Expressions Editor window,
type .05

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
56 Crystal Reports 11: Basic


Tell students that
they can also press Alt+C.
8 Click
(The Check button is on the toolbar.) To check
the formula. A message box appears stating that
no errors were found in the formula.

Click OK To close the message box.

9 Click Save and close (On the toolbar.) To save the formula and close
the Formula Editor window.
10 Show the Field Explorer The Salary Increase field is added under
Formula Fields.
Drag the Salary Increase field to
the Details section, and position it
next to the Start Date field

Tell students not to click
the Field Explorer, but to
position the pointer on it to
unhide it.
Tell students that if the
Field Explorer doesnt
rehide, they can put the
field anywhere in the
details section and move it
after the Field Explorer
hides again.
Drag the field header from the
Page Header section to the Group
Header #1 section, as shown

To line up the field header with the others.

Enlarge the field slightly So that the data is better displayed.
Tell students that they can
adjust the formatting of
the field header and field
to match those of the
others if they wish.
11 Deselect the field and preview the
report
(Scroll right.) The amount that is to be paid
appears in the Details section of the report.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 57

Topic B: Modifying formulas
Explanation You might need to modify or delete formulas in your reports. The Formula Editor helps
you do this.
Editing formulas

To edit a formula:
1 In the Details section on the Design tab, select the formula field.
2 Choose Edit, Edit Formula to open the Formula Editor window.
3 Make the changes to the formula.
4 Check the formula for errors.
5 Save the formula and close the Formula Editor window.
Do it! B-1: Editing a formula
Heres how Heres why

1 Activate the Design tab

2 In the Details section, select
@Salary Increase

Choose Edit, Edit Formula To open the Formula Workshop - Formula
Editor Salary Increase window.
Tell students that
they can also right-click
the field and choose Edit
Formula from the context
menu.
3 In the Formula text window, edit
the formula as shown

To multiply the Employees Earnings field
values by 1.05.

4 Check the formula for errors Click the Check button on the toolbar.

Click OK To close the message box stating that no errors
were found.

Save the formula and close the
Formula Editor window
Click the Save and close button on the toolbar.

5 Deselect the field

Preview the report The new salary increases are displayed.

6 Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
58 Crystal Reports 11: Basic

Renaming formulas
Explanation A good formula name should provide information about the contents of the formula
field. If you edit a formula, you should rename its field to reflect the change.
To rename a formula:

1 In the Field Explorer dialog box, select the formula field.
2 Click the Rename button on the toolbar in the Field Explorer dialog box.
3 Rename the formula field.
Do it! B-2: Renaming a formula
Heres how Heres why
1 Activate the Design tab
2 In Field Explorer, select Salary
Increase
(If necessary.) The Total amount field is under
the Formula Fields in the Field Explorer dialog
box.

Click
The Rename button is on the toolbar in the Field
Explorer dialog box.
Edit the box to read New Salary
Press e
To commit the name change.
Tell students that because
the formula now shows
the new salary amount,
they need to rename the
formula.
3 Observe the report In the Details section, the name of the formula
changes to @New Salary, but the field heading
remains the same.
4 In the appropriate Header section,
double-click Salary Increase
To edit the text object.
Edit the box to read New Salary
5 Deselect the field and preview the
report
The text object displays the new name.
The field heading may be
in either the Page or
Group Header #1
sections, depending on
where students placed it
earlier.
Tell students that they
might need to resize the
field.
6 Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 59

Deleting formulas
Explanation If you dont want to use a formula in a report, select it in Design view and press Delete.
When you no longer expect to need a formula field, you can also delete it from the Field
Explorer. To do so:

1 In the Field Explorer dialog box, select the Formula field.
2 Click the Delete button on the toolbar in the Field Explorer dialog box. A
message box warns you that after deleting a field, you cannot undo it.
3 Click Yes. The formula text object in the Page Header section is also deleted.
Do it! B-3: Deleting a formula
Heres how Heres why

1 Switch to Design view

2 In the Field Explorer, select New
Salary
If necessary

Click
(The Delete button is on the toolbar in the Field
Explorer dialog box.) A message box warns you
that deleting a field cannot be undone.

Click Yes (To delete the formula from the Details section.)
The New Salary text object is also deleted.

3 Preview and update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
510 Crystal Reports 11: Basic

Topic C: Functions
Explanation A function is a set of instructions used to perform specific tasks, such as evaluating,
modifying, or making calculations on data. Functions accept information as input, and
then calculate output for you. The input values for functions are called arguments,
which can be expressions or fields.
For example, the transaction dates stored in a table might include day, month, and year,
but you might want to see only the year in a report. To do so, you would specify the
transaction date as an argument of a function that will extract only the year.
In a function, arguments are enclosed in parentheses after the functions name. A
function can have more than one argument, and you use commas to separate multiple
arguments. A function has the following syntax:
Function(Argument1, Argument2, )
Crystal Reports provides several categories of functions, including Date/Time, String,
Mathematical, and Statistical.
Date and Time functions

You use Date and Time functions to insert dates and times, or to perform calculations on
dates, such as finding the difference between two dates. Date and Time functions
include CurrentDate, CurrentTime, Month (x), and Year (x). Month (x) takes a date as
an argument and returns the month, and Year (x) returns the year based on a given date.
To use the Date and Time functions to create a formula, open the Formula Workshop
window and select the function you want from the Functions pane. Select fields and
operators, if necessary. Save the formula and close the Formula Workshop window.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 511

Do it! C-1: Using a date function to return the current date
Heres how Heres why

1 Switch to Design view

2 In the Field Explorer, select
Formula Fields
(If necessary.) Youll add the current date to the
Report Header section.

3 Click
To open the Formula Name dialog box.

Type Date In the Name box.

Click OK The Formula Workshop - Formula Editor - Date
window appears.

4 Expand Functions as shown

To view the list of functions in the Functions
pane.

In the Functions pane, expand
Date and Time
To view the list of Date and Time functions.

Double-click CurrentDate CurrentDate appears in the Formula text
window.

5 Check the formula (Click the Check button and then click OK.) It is
good practice to always check your formulas.

6 Click Save and close To save the formula and close the window. Date
is added under Formula Fields in Field Explorer.

7 Drag Date from the Field
Explorer to the Page Header
section, as shown

Scroll left, if necessary.

Enlarge the field To display the whole date.

8 Preview the report The current date appears in the Page Header
section.

9 Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
512 Crystal Reports 11: Basic

The Month (x) function
You can use the Month (x) function to extract the month component of a date in your
report, where x is the value of that component, such as July or November. The Month
(x) function converts this component to a number.
Do it! C-2: Using the Month (x) function
Heres how Heres why
1 Switch to Design view
Tell students that
the Human Resources
Director wants a report
that shows the month
each employee was hired.
Create a new formula field named
Month
In the Field Explorer, select Formula Fields, and
click the New button. Name the field, and click
OK.

2 In the Formula Workshop, in the
Functions list, expand Date and
Time
If necessary.

3 Double-click Month (x) To add it to the formula.

4 From the Report Fields list,
double-click
Employees.Start_date
To add the field to the formula.

5 Check the formula

Save the formula and close the
Formula Workshop


6 Choose Insert, Group Youll add the new function to the report.

From the first list, select X-1
Month


Click OK To close the Insert Group dialog box.
Tell students that they will
change the way the month
is displayed in the next
activity.
7 Preview the report The data is now grouped by the month each
employee was hired. However, since the Month
(x) function converts the month to a number, the
actual month names are not displayed.

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 513

The MonthName function
While it can sometimes be useful to display a months numerical equivalent, such as
when you want to use it in a numeric calculation, youll often want to display the name
of the month in your report. To do this, you can use the MonthName function, which
will convert the number into a string, or text, value.
Do it! C-3: Using the MonthName function
Heres how Heres why

1 Switch to Design view

2 Right-click Group Header #2: To display a context menu.

Choose Change Group To open the Change Group Options dialog box.

3 Activate the Options tab

Check Customize Group
Name Field
To activate options for customizing the group
name.

Select Use a Formula as
Group Name


4 Click
To open the Formula Workshop-Group Name
Formula Editor.

5 From the Functions list, expand
MonthName


Double-click MonthName
(month)
To add it to the formula.

6 From the Report Fields list,
double-click X-1 Month
To add the formula field Month as the argument
for the new function.

Observe the formula

The MonthName function uses the formula field
created in the last activity as the argument to
return the name of the month.

7 Check the formula

Save the formula and close the
Formula Workshop
To return to the Change Group Options dialog
box.

Click OK To close the dialog box.

8 Preview the report The months are now displayed by name.

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
514 Crystal Reports 11: Basic

Concatenation
Explanation You may find it helpful to combine two fields into one text object to create a single
string expression, so that the field values appear together. For example, you may want
the first and last name of a customer to appear in a single object to avoid any spacing
issues. When you join one field to another in a new text object, this is called
concatenation, and is a function that can be inserted in a report without using the
Formula Workshop.
To concatenate two fields into one object, delete the fields and their headers from the
Design tab. Create a new text object in the report where you want the fields to appear,
and drag the desired fields from the Field Explorer to the new text object.


Exhibit 5-3: A portion of the report showing name fields concatenated
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 515

Do it! C-4: Combining field names and formulas
Heres how Heres why

1 Activate the Design tab

2 In the Details section, select the
First name and Last name fields


Press d
To delete the fields and headings. Youll
combine the data into one field.

3 Choose Insert, Text Object

In the Details section, click to the
right of the Employee Code field
To insert a text box.

4 In the Field Explorer, expand the
Database Fields list


Expand the Employees table If necessary.

Drag the First Name field into the
text object


Press q
To insert a space after the First Name field.

5 Drag the Last Name field to the
text box to the right of the First
Name

To create a single field from two separate fields.

6 Add a field header in the Group
Header #1 section, and format it
to look the same as the other field
headers
Choose Insert, Text Object. Type Name in the
box, and format it.

7 Preview the report It should look like Exhibit 5-3. There is now a
single name field.

Update and close the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
516 Crystal Reports 11: Basic

String functions
Explanation


You use string functions to manipulate text data. For example, you might want to take
only the first of several characters of a text string, or convert data to uppercase or
lowercase characters. String functions include UpperCase (str) and LowerCase (str), and
ProperCase (str). UpperCase (str) takes a string as an argument and returns it in
uppercase, LowerCase (str) returns its string argument in lowercase characters, and
ProperCase (str) returns its string argument with the first letter of each word capitalized.


Exhibit 5-4: The formula that converts text to proper case
Do it! C-5: Using a string function to convert text to proper case
Heres how Heres why

1 Open Transaction report From the current unit folder.

Save the report as My
transaction report


2 Observe the data in the Product
description field
The first letter of each product is in lower case.
Youll modify the field so that the products
appear in the proper case.

3 Activate the Design tab

4 Create a new formula called
Product name
The Formula Workshop Formula Editor
Product name window opens.

5 In the Functions pane, expand
Strings
(Scroll as necessary.) To view the list of Strings
functions.

Double-click ProperCase
(str)
ProperCase () appears in the Formula text
window.

6 In the Report Fields pane, double-click
Transaction.Product_description

The formula should match Exhibit 5-4.

Check the formula for errors

7 Save the formula and close the
Formula Editor window
Product name appears under Formula Fields in
Field Explorer.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 517



8 In the Details section, select
Product_description
Youll replace this field with the Product name
field.

Press d
To delete the Product_description field.

In the Page Header section, delete
Product description


9 Drag Product name from the
Field Explorer to the Details
section, as shown


In the Page Header section, move
the Product name field heading so
that it aligns with the other
headings


10 Deselect the field and preview the
report
The products now appear in proper case.

11 Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
518 Crystal Reports 11: Basic

The Left function
You can create other string functions that return a certain number of characters from a
particular part of a text string. For example, the Left function returns a specified number
of characters from the left side of the text string. This is useful for, say, obtaining only
the area code from a field that contains a phone number, or for displaying items in a
group alphabetically.


Exhibit 5-5: A portion of the report using the Left string function
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 519

Do it! C-6: Using the Left function
Heres how Heres why

1 Switch to Design view

2 Create a new formula field called
Alpha
Youll display the spices in alphabetical groups
within their date groupings.

3 In the Functions list, under
Strings, double-click
Left (str, length)
Youll specify both the string and the number of
characters to obtain from the left side of the
string.

4 Under Report Fields, double-click
X-1 Product name
To specify this field as the one containing the
string you want to extract characters from.

5 Press x
To position the insertion point to the right of the
comma in the formula.

Type 1

To return the first character in the text string in
the Product Name field.

6 Check the formula

Save the formula and close the
Formula Workshop


7 Choose Insert, Group

From the first list, select
X-1 Alpha


Click OK To close the Insert Group dialog box and insert
the new function into the report.

8 With the Group #2 Name field
selected, press x twice
To nudge the field to the right and set it off from
the Group #1 Name field.

9 Deselect the field and preview the
report
It should look like Exhibit 5-5. The product
names are now grouped alphabetically based on
the first character in the string.

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
520 Crystal Reports 11: Basic

Mathematical functions
Explanation


You use mathematical functions to perform calculations. For example, you could find
the remainder after dividing two numbers. Crystal Reports provides mathematical
functions such as Abs (x), Round (x), and Sqr (x). The Abs (x) function takes a number
as an argument and returns the absolute value. The Round (x) function takes a fractional
value as an argument and returns the rounded value. The Sqr (x) function takes a
number as an argument and returns the square root of the number.
Do it! C-7: Using a math function to round data
Heres how Heres why

1 Activate the Design tab

2 Create a new formula called New
price
Youll round off the Unit_price values.

3 In the Functions pane, expand
Math
(Scroll up.) To view the list of mathematical
functions.

Expand Round To view the list of round functions.

Double-click Round (x) Round () appears in the Formula text window.

In the Report Fields pane, double-
click Transaction.Unit_price


4 Check the formula for errors

5 Save the formula and close the
Formula Workshop


6 Drag New price from Field
Explorer to the Details section, as
shown


In the Page Header section, move
the field heading so that it aligns
with the other headings in the
section


7 Deselect the field and preview the
report
(Scroll right.) New price contains rounded off
values for unit price.

8 Update and close the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 521

Unit summary: Formulas and functions
Topic A In this topic, you learned how to use formulas to perform calculations. You learned that
formulas are made up of fields, text, numbers, functions, operators, and other formulas.
You also learned how to create formulas by using the Formula Workshop and the
Formula Editor.
Topic B In this topic, you learned how to modify formulas by editing them, as well as how to
rename them. You also learned how to delete formulas.
Topic C In this topic, you learned that functions are sets of instructions used to perform specific
tasks, such as evaluating, modifying, or making calculations on data. You learned how
to include functions in formulas, and that there are types of functions including Date
and Time, Concatenation, String, and Mathematical functions.
Independent practice activity
In this activity, youll practice creating and editing a formula, and using date and string
functions.
1 Open Employee Details from the current unit folder.
2 Save the report as My employee details.
3 Activate the Design tab, if necessary.
4 Outlander Spices has decided to give all its employees a bonus of 10%. Create a
formula named Bonus to calculate a bonus of 10% on the earnings of employees.
5 Drag the Bonus field into the report. Format the heading and align it so that it
matches the other text objects in the Page Header section.
6 Preview the report. It should look like Exhibit 5-6.
7 The company has decided to increase the bonus from 10% to 15%. Edit the formula
to increase the bonus.
8 Insert the current date and time in the Report Header section. (Hint: Create a new
formula field called Date and Time, select the CurrentDateTime function in the
Formula Workshop, and drag the new field into the report.)
9 Create a string expression (concatenation) that displays the First name and the Last
name fields. Insert a field heading named Employee Name.
10 Create a string function called Region that converts the text in the Region field to
uppercase. (Hint: The formula will be: UpperCase ({Employees.Region}).)
11 Preview the report. It should look like Exhibit 5-7.
12 Update and close the report.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
522 Crystal Reports 11: Basic




Exhibit 5-6: A portion of the report after step 6 of the Independent Practice Activity


Exhibit 5-7: A portion of the report after step 11 of the Independent Practice Activity
Review questions
1 In a formula, what does syntax refer to?
The rules used to create the formula. For example, text strings must be enclosed in quotes.
2 What are some components of a formula?
Fields
Numbers
Operators
Functions
Text
3 How do you create a formula field?
In the Field Explorer, choose Formula Fields and click the New Field button to open the Formula
Name dialog box, and then the Formula Workshop.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Formulas and functions 523

4 What is the input value for a function called?
An argument
5 What are some uses for Date and Time functions?
A To perform summary calculations.
B To create fields that can only be formatted conditionally.
C To insert dates and times.
D To perform calculations on dates.
6 What is the Month (x) function used for?
To extract the month component of a date in the report
7 Name a function that can be inserted in a report without using the Formula
Workshop.
The concatenation function
8 The Left function is an example of what type of function?
A string function
9 Which math function would you use to return the absolute value of a number
argument?
Abs (x)
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
524 Crystal Reports 11: Basic

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
61

Un i t 6
Experts and wizards
Unit time: 90 minutes
Complete this unit, and youll know how to:
A Add tables and link them by using the
Database Expert.
B Create reports by using the Standard
Report Creation Wizard and the Mailing
Labels Report Creation Wizard.
C Create a cross-tab report by using the
Cross-Tab Report Creation Wizard, and
modify and format cross-tab reports.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
62 Crystal Reports 11: Basic

Topic A: The Database Expert
Explanation A database is a collection of related tables. You can connect the tables in a database by
linking them based on a common field or fields. Linking helps you extract data from
two or more tables simultaneously. For example, consider an employee database with
three different tables: personal details, salary, and leave details. To display information
about employee details and salary in a single report, you would need to link two tables
by a common field, such as Employee_ID. To link tables, you use the Database Expert.
In Crystal Reports, the from table serves as the primary table, whereas the to table acts
as a lookup table. When you create a report, the Report Designer examines a record in
the from table and finds all the matching records in the to table.
Adding and linking tables
The Database Expert window will open automatically if you select two or more tables
on which to base a report. When you want to link tables, you must add the from table
first, then add the to table. You can then either link the tables manually or use the Smart
Linking option. To link tables manually, drag the common field from the from table to
the same field in the to table. The tables will be linked automatically based on fields that
have matching names and values. The tables appear linked by a line, as shown in
Exhibit 6-1.
You can also use the Database Expert to add or delete tables from a report.


Exhibit 6-1: The Database Expert window with the Links tab activated
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Experts and wizards 63



To add a table and link two tables:
1 Choose Database, Database Expert to open the Database Expert window.
2 From the Available Data Sources list, select the appropriate tables to link.
3 Click OK to close the Database Expert window.
4 Click OK to refresh the records.
5 Open the Field Explorer dialog box and add the appropriate fields from the
tables.
6 Preview the report.


Exhibit 6-2: The report after adding the Retailer name field
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
64 Crystal Reports 11: Basic

Do it! A-1: Adding a field from a linked table
Heres how Heres why

1 Open Linking report (From the current unit folder.) The report
contains transaction details. Youll link the
Transaction and Retailer tables so that you can
add the Retailer_name field.

2 Save the report as
My linking report

3 Choose Report, Refresh
Report Data
To update the report data with the data available
in the database. The Preview tab is activated.
Tell students that
they can also press F5.
Activate the Design tab

4 Choose Database, Database
Expert
To open the Database Expert window.

5 Expand Create New
Connection
If necessary.
Tell students that they
might have to maximize
the window. Also,
students screens might
look somewhat different
than the graphic pictured.
Click as shown

To expand the Experts database.

6 Under Experts database, select
Retailer


Click
To add the Retailer table.

Click OK To activate the Links tab.

7 Observe the Database Expert
window with the Links tab
activated
The Transaction and Retailer tables are linked
on the Retailer_code field.

Click OK To close the Database Expert window. Crystal
Reports prompts you to refresh the report data.

Click OK To refresh the records.

8 Activate the Design tab
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Experts and wizards 65



9 Show the Field Explorer Youll add the Retailer_name field.

Expand Database Fields The two tables, Retailer and Transaction,
appear.

Expand Retailer To display the fields in the table.

Drag the Retailer_name field to
the Details section, as shown


10 Edit the Retailer_name text object
to read Retailer name


Align the Retailer name text
object with the other text objects

Tell students to deselect
the text objects after
aligning.
Format the Retailer name heading
and field with the Times New
Roman font, 10 pt.
If necessary.

11 Preview the report The report now shows the Retailer name field,
as shown in Exhibit 6-2.

12 Update and close the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
66 Crystal Reports 11: Basic

Topic B: Report wizards
Explanation


Report wizards guide you through a step-by-step process for creating a report. Crystal
Reports provides wizards for creating various types of reports, including the following:
Standard
Mailing Labels
Cross-tab
OLAP (On-line Analytical Processing)
The Standard Report Creation Wizard
The Standard Report Creation Wizard helps you create basic types of reports. The
following table describes the different option screens of the Wizard.

Screen Used for

Data Selecting the data source

Links Linking tables in a report

Fields Specifying fields, creating formulas, and changing column headings

Group Specifying groups and sort order

Summaries Adding summary information such as subtotals to a report

Chart Inserting a chart

Record selection Creating subsets of information from a table by setting conditions

Templates Specifying a style

To use the Standard Report Creation Wizard to create a report:

1 On the Start Page, under New Reports, click Standard Report Wizard to open the
Standard Report Creation Wizard Data screen.
2 Expand Create New Connection, if necessary.
3 Double-click Make New Connection and select a data source for the report. If
you select more than one table, the Links screen will be active and the tables will
be linked.
4 Click Next to activate the Fields screen and select the fields you want to include.
5 Use any of the remaining screens for the other features you want to include in
your report.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Experts and wizards 67



Exhibit 6-3: A report created by using the Standard Report Creation Wizard
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
68 Crystal Reports 11: Basic

Do it! B-1: Using the Standard Report Creation Wizard
Heres how Heres why
Tell students that
they will use the Standard
Report Creation Wizard to
create a sales report that
is grouped by product.
1 On the Start Page, under New
Reports, select Standard
Report Wizard
To open the Data screen of the Standard Report
Creation Wizard.
Tell students to expand
the window, if necessary.
2 Under Access/Excel (DAO),
expand the Experts database
If necessary.

Under Experts database,
double-click Transaction
To add it to the Selected Tables list.

Add Product (Double-click it.) Product appears in the
Selected Tables list.

3 Click Next The Link screen appears, with the Transaction
and Product tables linked by their common field,
Product_code.

4 Click Next To activate the Fields screen.

5 Expand Transaction

Under Transaction, select
Transaction_code
Youll add this field to the report.
Click
To add Transaction_code to the Fields to
Display list.
Tell students that
they can also double-click
Transaction_code to add it
to the list.
Add Product_description to
the Fields to Display list
Located under Product.

Under Transaction, add the
Transaction_date, Retailer_code,
and Quantity_sold fields, as
shown

The Fields to Display list should look like this.

6 Click Next To activate the Grouping screen.

From the Available Fields list,
select Product.Product_description

Youll group the records by this field.

Click
(Or double-click the field.)
Product.Product_description appears in the
Group By list.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Experts and wizards 69



7 Click Next To activate the Summaries screen.

From the Summarized Fields list, select
Sum of Transaction.Transaction_code

Click
To remove the field. Youll calculate the
subtotal only for the Transaction.Quantity_sold
field.

8 Click Next To activate the Group Sorting screen.

Verify that in the Group that will
be sorted list,
Product.Product_description, is
selected
To group the report according to
Product.Product_description.

9 Click Next To activate the Chart screen. You wont be
using a chart in this report.

10 Click Next To activate the Record Selection screen.

11 Click Next To activate the Template screen.

In the Available Templates list,
select Block (Blue)
To apply this template to the report.

12 Click Finish To preview the report. The report shows sales
information grouped by product. However, some
fields overlap, causing the data to be unreadable.

13 Activate the Design tab
Allow students time to
modify the fields.
Rearrange and resize the report
fields as necessary
To completely view the data in the report fields.
The report should look like the one shown in
Exhibit 6-3.

14 Save the report as
My product sales report
In the current unit folder.

15 Close the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
610 Crystal Reports 11: Basic

The Mailing Label Report Creation Wizard
Explanation You can use the Mailing Label Report Creation Wizard to create different types of
labels. This wizard contains five tabs: Data, Link, Fields, Label, and Record Selection.
The Label screen helps you specify the type and size of the label you want. You can
either select the style from a list or create your own.
To create a mailing label report:

1 On the Start Page, select the Mailing Label Report Wizard.
2 Add tables.
3 Add fields.
4 Choose the label type.
5 Select records.


Exhibit 6-4: A portion of the report created by using the Mailing Label Report Creation
Wizard
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Experts and wizards 611

Do it! B-2: Using the Mailing Label Report Creation Wizard
Heres how Heres why

1 On the Start Page, select Mailing
Label Report Wizard
To open the Data screen. Youll select a data
source for the mailing labels.

In the Available Data Sources list,
under Create New
Connection/Access/Excel (DAO),
double-click Make New
Connection
To open the Access/Excel (DAO) dialog box.

Click
To browse for the data source. The Open dialog
box appears.

2 In the Look in list, navigate to the
current unit folder
If necessary.

Select membership This is the data source you will use.

Click Open

Click Finish To close the dialog box.

3 Double-click tblMembership To add it to the Selected Tables list.

Click Next To activate the Fields screen.

4 From the Available Fields list,
select the strFirstName field


Press c and click the
strLastName, strAddr1, strAddr2,
strCity, strState, and
strPostalCode fields
To select them in addition to the strFirstName
field.

Click
To add all the selected fields to the Fields to
Display list.

5 Click Next To display the Label screen.

From the Mailing Label Type list,
select the indicated label type


6 Click Next To display the Record Selection screen.

Click Finish To complete the Wizard and preview the report.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
612 Crystal Reports 11: Basic



7 Observe the labels The field arrangement doesnt use the space
very efficiently.

8 Activate the Design tab Notice that the first set of fields is not
highlighted. These are the fields you can edit.

Concatenate the strFirstName and
strLastName in a single text object
Delete the fields, then insert a text object. Drag
the strFirstName and strLastName fields from
the Field Explorer to the text object.

Arrange the label so that the City,
State, and Postal Code appear on
one line
Concatenate the fields into a new text object.

9 Deselect the fields and preview
the report
It should look like Exhibit 6-4.

10 Save the report as My mailing
labels
In the current unit folder.

Close the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Experts and wizards 613

Topic C: Cross-tab reports
Explanation The Cross-Tab Report Creation Wizard helps you to create a report in which data is
shown as a cross-tab object. A cross-tab report presents data in columns and rows, with
values grouped and summarized in both directions. Cross-tab reports display complex
data in a manner that makes it easier to understand.
The Cross-Tab Report Creation Wizard contains six screens, two of whichCross-Tab
and Grid Styleare unique to it. The Cross-Tab screen helps you to create the cross-tab
report, and the Grid Style screen helps you format it.
Cross-tab objects

The cross-tab object in a cross-tab report consists of three parts: rows, columns, and
summaries. Rows display data from one field; columns, which run vertically, display
data from a second field. The value shown at each intersection summarizes the values of
those records that meet the row and column criteria.
In the example shown in Exhibit 6-5, the rows of the cross-tab object display data from
the Retailer name field, and the columns display data from the Product name field. The
summary values represent the sums of the quantities of each product sold to each
retailer. The report displays the total quantity sold for a specific product at the lower
region of the products column, and the total quantity sold to a specific retailer at the
end of the retailers row.


Exhibit 6-5: An example of a cross-tab report
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
614 Crystal Reports 11: Basic

To create a cross-tab report:

1 On the Start Page, select Cross-Tab Report Wizard.
2 Add tables.
3 Activate the Cross-Tab screen. Add fields for rows, columns, and summary. It
will look something like Exhibit 6-6.
4 Activate the Grid Style tab. Select a grid style for the report.
5 Click Finish to preview the report.

Exhibit 6-6: The report created by using the Cross-Tab Report Creation wizard
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Experts and wizards 615

Do it! C-1: Creating a cross-tab report
Heres how Heres why

1 On the Start Page, select Cross-
Tab Report Wizard
To open the Cross-Tab Report Creation Wizard
dialog box. The Data screen is active.

From the Membership database
add the tblMembership table to
the Selected Tables list


Click Next To go to the Cross-Tab screen.

2 From the Available Fields list,
select strMembershipType


Click as shown

To add strMembershipType as a summary field.

From the summary list, select
Count
To calculate a count of membership types.

3 Add the strState field to the
Columns box
Select the field and click the arrow next to the
Columns box.

Add the strMembershipType field
to the Rows box
Youll calculate the count of membership types
by state.

4 Click Next three times To activate the Grid Style screen. Youll keep
the default grid style.

Click Finish To close the Wizard and create the report.

5 Observe the report It should look like Exhibit 6-6.

6 Save the report as
My crosstab report


P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
616 Crystal Reports 11: Basic

Creating groups in a cross-tab report
Explanation You can group data in a specified order in a cross-tab report to enhance how your data
appears. For example, you may want to group best-selling products at the top of the
report, and least-popular products at the bottom.
To group data in a specified order in a cross-tab report:
1 On the Design tab, right-click Row #1 Name in the Details section.
2 Select Row Options, Group Options from the context menu.
3 Select in specified order from the order list to open the Specified Order tab.
4 On the Specified Order tab, name the group, and click New.
5 Select the desired options in the Define Named Group dialog box, and click OK.
6 Click OK to close the Cross-Tab Group Options dialog box and apply the new
order.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Experts and wizards 617

Do it! C-2: Grouping data in a cross-tab report
Heres how Heres why

1 Activate the Design tab

2 Right-click the Row #1 Name
field
To display a context menu.

From the menu, select Row
Options, Group Options
To open the Cross-Tab Group Options dialog
box.

3 From the second list, select in
specified order
To activate the Specified Order tab.

Click New To open the Define Named Group dialog box.

4 In the Group Name box, enter
General


From the list, select is equal to Another list box appears.

From the second list, select Basic The General group will contain records of
members with a Basic membership.

Click OK To close the Define Named Group dialog box.

5 Click New Youll define a second grouping.

Name the new group Principal

6 From the list, select is one of

From the second list, select
Board, Extended, and Senior
To add other membership types to the new
grouping.

7 Click OK To close the Define Named Group box.

Click OK To close the Cross-Tab Group Options dialog
box and apply the new groupings.

8 Preview the report

Update the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
618 Crystal Reports 11: Basic

Formatting cross-tab reports
Explanation You can change the appearance of a cross-tab report by changing the width, height, and
background color of the rows and columns. You can format the gridlines by changing
their style, width, or color.
To format a cross-tab report:

1 Activate the Design tab.
2 Right-click the blank top-left area of the report. Choose Cross-Tab Expert to
open the Cross-Tab Expert dialog box.
3 Activate the Style tab. You can then select a general, pre-defined style to apply
to the report.
4 If you want to customize the style, activate the Customize Style tab, and choose
your desired options.
5 Click OK to close the Cross-Tab Expert dialog box.

Exhibit 6-7: The cross-tab report after formatting
Do it! C-3: Formatting a cross-tab report
Heres how Heres why

1 Activate the Design tab

2 Right-click on the blank space in
the upper left of the report
To open a context menu.

In the menu, select the indicated

To open the Cross-Tab Expert dialog box.

3 Activate the Style tab

From the Style list, select Silver
Sage 1
A preview of the style appears in the right-hand
pane.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Experts and wizards 619



4 Click OK A message box appears asking if you want to
keep the new style and lose any customized
formatting you may have done.

Click Yes To close the message box and apply the new
style

5 Preview the report The report is displayed with the new style.

6 Activate the Design tab Youll customize the new style.

7 Open the Cross-Tab Expert Right-click the blank area in the upper-left of
the report and choose Cross-Tab Expert from the
menu.

8 Activate the Customize Style tab

Under Rows, select Grand
Total
You apply a different color to the Total field to
set it apart from the rest of the report.

From the Background Color list,
select the indicated color

To apply Lime as the background color for the
Total field.

Click OK To close the Cross-Tab Expert and apply the
customized style.

9 Preview the report It should look like Exhibit 6-7.

Update and close the report

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
620 Crystal Reports 11: Basic

Unit summary: Experts and wizards
Topic A In this topic, you learned how to add and link tables by using the Database Expert.
You learned that linking helps you to extract data for a report from two or more tables.
Topic B In this topic, you learned how to create reports by using various report wizards, which
guide you through a step-by-step process of creating reports. You learned how to create
reports by using the Standard Report Creation Wizard and Mailing Labels Report
Creation Wizard.
Topic C In this topic, you learned how to create a cross-tab report by using the Cross-Tab
Report Creation Wizard. You also learned how to group data in and format a cross-
tab report.
Independent practice activity
In this activity, youll practice creating new reports using the Database Expert, and
report creation wizards. Notice that the first four steps of this activity can all be
performed from within the Standard Report Creation Wizard.
1 Use the Transaction and Retailer tables from the Experts database to create a report
that contains the following fields: Transaction_code, Transaction_date,
Product_code, Retailer_name, and Quantity_sold.
2 Group the records by Retailer_name.
3 Calculate subtotals for only the Quantity_sold field.
4 Select Gray Scale as the report template.
5 Rearrange the report fields for better display. Preview the report. It should look
similar to Exhibit 6-8.
6 Save the report as My sales detail and close it.
7 Create a report by using the Mailing Labels Report Creation Wizard. The report
should be based on the Retailers table from Retailerdatabase, and should include
the following fields: Retailer_name, Address, City, State, and Zip. Specify the type
of label as Address (Avery 5160).
8 Preview the report. The report should look like Exhibit 6-9.
9 Save the report as My retailer labels and close it.
10 Create a report using the Cross-Tab Report Creation Wizard based on
Retailerdatabase. Add both the Orders and Retailers tables to the Selected Tables
list. From Retailers, choose Retailer Name as the row heading, Product
Description as the column heading, and the sum of Quantity Sold as the Summary
field.
11 Increase the widths of the row and column headings so that they show all the text.
12 Change the background color of the Orders.Product_description columns to Aqua.
13 Preview the report. It should look like Exhibit 6-10.
14 Save the report as My summary sales detail and close it.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Experts and wizards 621



Exhibit 6-8: The report should look like this after step 5 of the Independent Practice
Activity


Exhibit 6-9: The report should look like this after step 8 of the Independent Practice
Activity

Exhibit 6-10: A portion of the report after step 12 of the Independent Practice Activity
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
622 Crystal Reports 11: Basic

Review questions
1 To extract data from two or more tables, you must
A Link them based on a common field or fields
B Have all tables open at the same time
C Import the data from one or more tables into another table
D Use the Select Expert to select data from each table that you want to display in
your report
2 One of the easiest ways to create a report in Crystal Reports is to
A Have your administrative assistant do it.
B Use a Report Wizard.
C Copy another report and change the data source and layout.
D Import records from an Excel spread sheet.
3 What does OLAP stand for?
On-line Analytical Processing
4 A quick method of creating mailing labels is to ___________
Use the Mailing Label Report Wizard
5 How does a cross-tab report display data?
In rows and columns
6 How would you group data in a cross-tab report?
By using the Cross-Tab Group Options dialog box
7 To assist you in formatting a cross-tab report, which Expert would you use?
The Cross-Tab Expert
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
71

Un i t 7
Distributing reports
Unit time: 60 minutes
Complete this unit, and youll know how to:
A Export a report to Microsoft Excel, HTML
4.0, XML, and Access file formats, and
create report definitions.
B Print a report and send a report via e-mail.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
72 Crystal Reports 11: Basic

Topic A: Exporting reports
Explanation At times, you might need to distribute data to colleagues who dont have Crystal
Reports installed on their computers. You can do this by exporting the report to other
formats. To export data, you use the Export dialog box in which you specify the format
type and destination.
Format type refers to formats, such as Microsoft Excel, Microsoft Word, and HTML.
Destination refers to the location to which to send the file, such as disk file, application,
or Microsoft MAPI (e-mail.) If you specify disk file as the destination, the report is
saved on a disk, either the hard disk or a floppy disk. If you specify application, the
report is saved in a temporary file and opened in the application you specify. For
example, if you export a report in HTML format and specify application as the
destination, the report will open in a Web browser.
Exporting to Microsoft Excel format
To export a report to Microsoft Excel:

1 Open the report you wish to export.
2 Choose File, Export, Export Report to open the Export dialog box.
3 From the Format list, select an Excel format.
4 From the Destination list, select the destination.
5 Click OK to open the Excel Format Options dialog box.
6 Click OK to open the Select Export File dialog box and save the file in a folder
of your choice.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Distributing reports 73

Do it! A-1: Exporting a report to Microsoft Excel
Heres how Heres why

1 Open Export report In the current unit folder.
2 Choose File, Export, Export
Report
To open the Export dialog box.
Tell students that
they can also click the
Export button on the
Standard toolbar. Click the Format drop-down
arrow
To display the list. It contains various file
formats to which you can export the report,
including PDF, XML, and RTF.
From the Format list, select
Microsoft Excel 97-2000
(XLS)
To export the report in Excel format.
Tell students that
the sales manager needs
to see the sales report in
Microsoft Excel format.
In the Destination list, verify that
Disk file is selected
Youll save the report directly to the disk.

3 Click OK To open the Excel Format Options dialog box.

4 Click OK To open the Select Export File dialog box.

5 From the Save in list, navigate to
the current unit folder


Edit the File name box to read
My export report


6 Click Save To open the Exporting Records dialog box and
export the report. The dialog box closes when
the export action is finished.
7 Start Microsoft Excel 2003 Choose Start, All Programs, Microsoft Office,
Microsoft Excel 2003.
In Microsoft Excel, choose
File, Open
To display the Open dialog box.
If Microsoft Excel is
not installed, skip the rest
of this activity.
Help students navigate to
the file.
In the Look in list, navigate to the
current unit folder


Select My export report and
click Open


8 Observe the report The report now appears as a Microsoft Excel
worksheet.

Close the report

9 Close Microsoft Excel

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
74 Crystal Reports 11: Basic

Exporting to HTML 4.0 format
Explanation


If you want to display a report in a Web browser, you can export the report to HTML
format. To export a report to HTML 4.0 format:
1 Open the report you want to export.
2 Choose File, Export to open the Export dialog box.
3 From the Format list, select HTML 4.0.
4 From the Destination list, select the destination.
5 Click OK to open the Select Export File dialog box.
6 Edit the Directory Name box to give a name to the folder. From the list, select
the folder in which you want to create that folder.
7 In the Base File Name box, enter a name for the file.
8 Click OK to export the report.


Exhibit 7-1: The Select Export File dialog box
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Distributing reports 75




Exhibit 7-2: The report exported to HTML format
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
76 Crystal Reports 11: Basic

Do it! A-2: Exporting a report to HTML 4.0
Heres how Heres why

1 Click
(The Export button is on the standard toolbar.)
Or choose File, Export, Export Report. To open
the Export dialog box.
From the Format list, select
HTML 4.0
Youll export the report in this format.
Tell students that
Outlander Spices wants to
publish this information on
its Web site. From the Destination list, select
Application
This option saves the report to a temporary file
in the format specified in the Format list. The
report will then open in the associated
application.

Click OK To open the Select Export File dialog box.

2 Edit the Directory Name box to
read My HTML report
Youll save the exported HTML file in this
folder.

In the list, navigate to the current
unit folder
The My HTML reports folder will be created in
this folder.

Verify that the Base File Name
box reads Export report.html
The dialog box should look like Exhibit 7-1.

Click OK To open the Exporting Records dialog box. The
My HTML report opens in the browser, as
shown in Exhibit 7-2.
Tell students to leave the
report open; theyll use it
in the next activity.
3 Close the browser

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Distributing reports 77

Exporting to XML
Explanation Extensible Markup Language (XML) is a markup language like HTML, except that it
was designed to describe data rather than display it. XML has become increasingly
important in electronic publishing and in the exchange of data. For more information
about XML and how it can be used, take a look at the following Web site:
www.xmlfiles.com/xml/default.asp
To export a report to XML:

1 Open the report you wish to export.
2 Choose File, Export, Export Report.
3 In the Export dialog box, select XML from the Format list.
4 Select the destination, and then click OK to open the Export To Directory dialog
box.
5 Enter a directory name, select a destination folder, and enter the name of the file.
6 Click OK to export the report. You can then view the XML version of the report
in your browser, but to make real use of the file, you would need XML parsing
software or an XML publishing system.


Exhibit 7-3: The Export To Directory dialog box
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
78 Crystal Reports 11: Basic

Do it! A-3: Exporting a report to XML
Heres how Heres why

1 Open the Export dialog box

From the Format list, select XML Youll export the report in this format.

From the Destination list, select
Disk file


Click OK To open the Export To Directory dialog box.

2 Edit the Directory Name box to
read My XML report
Youll save the exported XML file in this folder.

In the list, navigate to the current
unit folder
The My XML report folder will be created here.

Edit the Base File Name box to
read My export report.xml
The dialog box should look like Exhibit 7-3.

Click OK The Exporting Records dialog box appears
briefly.
3 Open Windows Explorer Right-click the Start button and choose Explore. Make sure students use
Windows Explorer and not
Internet Explorer.
Navigate to the current unit folder

Open the My XML report folder
4 Double-click
My_export_report
To open the XML file in the browser.
If the Open With
dialog box appears, have
students select Internet
Explorer to open this file.
Observe the format Crystal Reports has added the XML tags in the
report. This is not of much use to an end user,
but the data can be used in publishing
applications.

5 Close the browser

6 Close Windows Explorer

7 Close the report Click No if you are prompted to save changes.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Distributing reports 79

Exporting to Microsoft Access
Explanation


You might need to save the report data to a database. You do this by exporting reports
generated by Crystal Reports to the Access database format. To export reports to the
Access database format, youll have to create a system Data Source Name (DSN) first in
the ODBC Data Source Administrator. Then, youll associate the DSN to the required
database.


Exhibit 7-4: The Database Expert showing the DSN and the associated table
Do it! A-4: Exporting a report to an Access database
Heres how Heres why
Help students navigate to
Administrative Tools in the
Windows Control Panel.
1 Navigate to
Administrative Tools
(Choose Start, Control Panel, Performance and
Maintenance, Administrative Tools.) To open
Data Sources to create a system DSN.

Double-click
Data Sources (ODBC)
To open the ODBC Data Source Administrator
dialog box.
2 Activate the System DSN tab
Ensure that
students select the
System DSN tab, and not
the User DNS tab.
3 Click Add To open the Create New Data Source dialog
box.

Under Select a driver for which
you want to set up a data source,
select Microsoft Access
Driver (*.mdb)


Click Finish To open the ODBC Microsoft Access Setup
dialog box.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
710 Crystal Reports 11: Basic



4 In the Data Source Name box,
enter StudentDSN
To name the DSN that youll use to connect to
the Employees table.

Under Database, click Select To open the Select Database dialog box.

Under Directories, open the
current unit folder
Youll select a database from the folder.

Under Database Name, select
Employees.mdb


Click OK To associate the DSN to the Employees database
and close the Select Database dialog box.

5 Click OK To close the ODBC Microsoft Access Setup
dialog box and return to ODBC Data Source
Administrator dialog box.

Observe the System Data Sources
list
Notice that StudentDSN is now added to the list.

Click OK To close the ODBC Data Source Administrator
dialog box.

6 Switch to Crystal Reports

7 Activate the Start Page If necessary.

Select Blank Report To open the Database Expert dialog box.
Tell students to scroll
down in the list, and/or
maximize the window.
8 In the Available Data Sources list,
under Create New Connection,
expand ODBC (RDO)
To open the ODBC (RDO) dialog box.

9 In the Data Source Name list,
select StudentDSN

Student dialog boxes
might not exactly match
the graphic.
Click Finish The Database Expert dialog box opens with the
StudentDSN and its associated table, as shown
in Exhibit 7-4.
10 Double-click Employees To add Employees to the Selected Tables list. Tell students that they
might have to scroll up.
Click OK To apply the changes and close the Database
Expert dialog box.

11 In the Field Explorer, expand
Database Fields


Expand Employees To display all the fields in the Details table.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Distributing reports 711


Tell students that they
might have to align the
fields.
12 Drag Employee_code,
First_name, Last_name,
Department, and Earnings to
the Details section of the report


Delete all field headings (From the Page Header section.) To prevent
exporting field headers to the Access table.

Preview the report
13 Open the Export dialog box Tell students to deselect
all the selected fields, if
any.
From the Format list, select
ODBC
Notice that the Destination box is disabled with
Disk file selected.

Click OK To open the ODBC Formats dialog box.

14 Select StudentDSN

Click OK To open the Enter ODBC Table Name dialog
box.
Edit the Table Name box to read
MY_EMPLOYEE_DETAILS
_REPORT
Notice that the table name appears in uppercase. Tell students that the
name theyll enter in the
Table Name box will
always appear in
uppercase.
15 Click OK The Exporting Records dialog box appears
briefly.

16 Start Microsoft Access Choose Start, All Programs, Microsoft Office,
Microsoft Access 2003.
Open the Employees database From the current unit folder. If a security warning
appears, tell students to
click Open.
Open MY_EMPLOYEE_DETAILS_REPORT

Notice that all the report fields and values are
added to the table in the order of their
appearance in the report.
Close the table and close
Microsoft Access
Tell students to click Yes if
they are prompted to save
the file.
17 Switch to Crystal Reports If necessary.

Save the report as
My employee report


P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
712 Crystal Reports 11: Basic

Report definition
Explanation


You can view the structure and properties of a report, such as group definition and
section information, by creating a report definition. A report definition consists of five
main sections: File Information, Record Sort Fields, Group Sort Fields, Formulas, and
Sectional Information.
Do it! A-5: Creating a report definition
Heres how Heres why

1 Open the Export dialog box

2 From the Format list, select
Report Definition (TXT)
To create a report definition for this report.

3 In the Destination list, select
Application


4 Click OK To open the report definition in Notepad.
Tell students to maximize
the Notepad window.
Observe the report definition The report definition gives details of the report
generated.

Close the Notepad window Click No if you are prompted to save changes.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Distributing reports 713

Topic B: Delivering reports
Explanation You might need to send a report to several of your companys branch offices. To do so,
you can either print several copies of the report and distribute them, or send the report
via e-mail.
Printing reports
You use the Print dialog box to print a report. You can choose to print either the entire
report or only a range of pages. You can also specify how many copies to print.
To print a report, choose File, Print, Printer to open the Print dialog box. Under Page
Range, select an option and click OK.



Exhibit 7-5: The Print dialog box
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
714 Crystal Reports 11: Basic

Do it! B-1: Printing a report
Heres how Heres why
1 Choose File, Print To open the Print dialog box.
Observe the dialog box You use this dialog box to choose the printer to
use, to specify the pages that you want to print
and the number of copies that you need. You
can check the Collate Copies option to print the
pages in order. This means that if you are
printing five copies of a report, Crystal Reports
will first print all the pages of one set and then
print the next set.
Students do not
necessarily need a printer,
but a printer driver must
be installed to complete
this activity.
Tell students that
they can also press
Ctrl+P.
If a message about
configuring a printer
appears, students should
click Yes.
2 Under Page Range, verify that All
is selected
To print the entire report.

Edit the Copies box to read 2 To print two copies of the report.

Observe the Print dialog box It should look like Exhibit 7-5.
3 Click Cancel To cancel printing the report. If a classroom printer has
been set up, students can
click the Print button.
4 Close the report Click No if you are prompted to save changes.

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Distributing reports 715

Mailing reports
Explanation You can also send the report as an e-mail attachment in formats such as Microsoft
Excel, HTML 4.0, or Crystal Reports. Youll need to specify an e-mail destination, such
as Microsoft MAPI or another e-mail program.
To send a report via e-mail:
1 Choose File, Export to open the Export dialog box.
2 From the Format list, select a format for the report.
3 From the Destination list, select MAPI.
4 Click OK to open the Send Mail dialog box, as shown in Exhibit 7-6.
5 In the To box, enter the e-mail address of the recipient.
6 In the Subject box, enter the subject of the e-mail message.
7 In the Message box, enter a message and click Send to mail the report.



Exhibit 7-6: The Send Mail dialog box
Do it! B-2: Mailing a report
Questions and answers
1 The sales manager does not have Crystal Reports installed. Can you mail a report
in another format?
Yes, you can mail a report in other formats, such as MS Excel or HTML 4.0.
Tell students that a mail
program has not been
configured on their
computers, so they cannot
send e-mail. If a mail
program is set up on your
computer, you might want
to demonstrate how to
send a report in this way.
2 What dialog box helps you to select a format and destination when mailing a
report?
The Export dialog box

3 To mail a report, what destination do you specify?
MAPI or another e-mail program

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
716 Crystal Reports 11: Basic

Unit summary: Distributing reports
Topic A In this topic, you learned how to export a report to other formats. You learned that you
can export reports to Microsoft Excel, HTML 4.0, XML, and Access formats so that
users who dont have Crystal Reports installed on their computers can view them. Then,
you learned how to create report definitions.
Topic B In this topic, you learned how to print a report and send a report via e-mail. You learned
that to mail a report, you need to specify an e-mail destination, such as Microsoft MAPI
or another e-mail program.
Independent practice activity
In this activity, youll practice exporting a report to two different formats, and then
viewing them in their new formats.
1 Open Employee report.
2 Export Employee report to XML format, as a disk file. Save it in the current unit
folder, in a directory you name My practice XML. Name the base file My practice
XML report.
3 Use Windows Explorer to navigate to the current unit folder.
4 Open the My practice XML report folder and view the report.
5 Close the browser window, and switch to Crystal Reports.
6 Export Employee report to Microsoft Word (RFT) format as a disk file. Give it the
name My practice employee details, and save it in the current unit folder.
7 Use Windows Explorer to navigate to the My practice employee details file and
view the report. Close the report and close Word.
8 Close Windows Explorer and close Crystal Reports XI.
Review questions
1 How can you share report data with a colleague who doesnt have Crystal Reports?
You can export the data to a format that the colleague can use, such as Excel, Word, or HTML.
2 What is the procedure for exporting report data to another format?
1 Open the report you wish to export
2 Choose File, Export, Export Report
3 Choose the format you want to export the data to
4 Choose the destination of the exported data
3 You want to export data so that it can be read in a Web browser. Which format do
you choose?
HTML 4.0
4 To export data to a Microsoft Access database, what is the first step you must take?
You must create a system DSN in the ODBC Data Sources Administrator, then associate the
DSN with the database.
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
Distributing reports 717

5 Name two sections of a report definition.
File information
Record sort fields
Group sort fields
Formulas
Sectional information
6 What are two methods of delivering reports?
Printing and e-mailing
P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE
718 Crystal Reports 11: Basic

P
R
E
V
I
E
W
NOT FOR PRINTING OR INSTRUCTIONAL USE

You might also like