Sie sind auf Seite 1von 232

Learners Guide

BOC320

For internal use by CSC only

For internal use by CSC only

Crystal Reports 2008: Report Design II Business Reporting Solutions

Copyright
2009 SAP BusinessObjects. All rights reserved. SAP
BusinessObjects owns the following United States patents, which
may cover products that are offered and licensed by SAP
BusinessObjects and/or affliated companies: 5,295,243; 5,339,390;
5,555,403; 5,590,250; 5,619,632; 5,632,009; 5,857,205; 5,880,742;
5,883,635; 6,085,202; 6,108,698; 6,247,008; 6,289,352; 6,300,957;
6,377,259; 6,490,593; 6,578,027; 6,581,068; 6,628,312; 6,654,761;
6,768,986; 6,772,409; 6,831,668; 6,882,998; 6,892,189; 6,901,555;
7,089,238; 7,107,266; 7,139,766; 7,178,099; 7,181,435; 7,181,440;
7,194,465; 7,222,130; 7,299,419; 7,320,122 and 7,356,779. SAP
BusinessObjects and its logos, BusinessObjects, Crystal Reports,
Rapid Mart, Data Insight, Desktop Intelligence, Rapid
Marts, Watchlist Security, Web Intelligence, and Xcelsius
are trademarks or registered trademarks of Business Objects,
an SAP company and/or affiliated companies in the United
States and/or other countries. SAP is a registered trademark
of SAP AG in Germany and/or other countries. All other names
mentioned herein may be trademarks of their respective owners.

For internal use by CSC only

For internal use by CSC only

C O N T E N T S
Course introduction...................................................................................................xiii
Course description.....................................................................................................xiv
Course audience.........................................................................................................xiv
Prerequisites................................................................................................................xiv
Additional education ................................................................................................xiv
Level, delivery, and duration...................................................................................xiv
Applicable certifications and designations.............................................................xiv
Course success factors.................................................................................................xv
Course setup.................................................................................................................xv
Course materials..........................................................................................................xv
Learning process.........................................................................................................xvi

Lesson 1

Using the Repository and Repository Data


Sources
Lesson introduction.......................................................................................................1
Using the Repository.....................................................................................................2
The repository ........................................................................................................2
Adding folders to the repository.........................................................................4
Activity: Adding folders to the repository.........................................................4
Adding objects to the repository..........................................................................5
Activity: Using objects in the repository.............................................................5
Updating repository objects..................................................................................6
Deleting items from the repository......................................................................6
Activity: Modifying objects and updating reports............................................7
Creating a report from a repository data source.......................................................9
SQL Commands .....................................................................................................9
Creating a report from a BusinessObjects universe..........................................9
Defining the data selection for a query.............................................................10
Setting data source location................................................................................11
Activity: Creating a report from a repository data source.............................11
Quiz_ Using the repository and repository data sources......................................14
Lesson summary..........................................................................................................15

Table of ContentsLearners Guide

iii

For internal use by CSC only

For internal use by CSC only

About this Course

Lesson 2

Creating Formulas

For internal use by CSC only

Lesson 3

Managing Reports
Lesson introduction ....................................................................................................45
Using the Workbench .................................................................................................46
Viewing the Workbench......................................................................................46
Organizing Workbench contents locally ..........................................................47
Publishing to BusinessObjects Enterprise................................................................48
Creating a new object package...........................................................................48
Adding an existing object package to the Workbench...................................48
Using the Publishing Wizard.............................................................................49
Activity: Publishing and viewing reports in BusinessObjects
Enterprise..............................................................................................................50

iv

Business Reporting SolutionsLearners Guide

For internal use by CSC only

Lesson introduction.....................................................................................................17
Using functions and operators...................................................................................18
Defining functions and operators .....................................................................18
Using help when creating formulas..................................................................18
Using string functions and operators ...............................................................19
String operators ...................................................................................................20
Activity: Defining string functions and operators...........................................22
Using nested string functions and operators ..................................................23
Activity: Using string functions and operators................................................23
Using numeric functions ....................................................................................24
Activity: Using numeric functions.....................................................................25
Using date and time functions ..........................................................................28
Activity: Defining date and time functions and operators............................31
Activity: Using date and time functions and operators.................................31
Using arithmetic operators.................................................................................32
Using Boolean operators ....................................................................................33
Activity: Using Boolean operators.....................................................................34
Defining control structures in Crystal syntax..........................................................36
Using basic if-then-else statements ...................................................................36
Activity: Using an if-then-else statement..........................................................36
Using multiple if-then-else statements ............................................................37
Activity: Using multiple if-then-else statements.............................................37
Using nested if-then-else statements.................................................................38
Activity: Using nested if-then-else statements.................................................39
Using Select statements.......................................................................................40
Activity: Using Select statements.......................................................................41
Quiz: Creating formulas ............................................................................................43
Lesson summary .........................................................................................................44

For internal use by CSC only

Lesson 4

Using Variables and Arrays


Lesson introduction ....................................................................................................63
Using variables.............................................................................................................64
Defining variables................................................................................................64
Declaring a variable ............................................................................................64
Assigning a value to a variable .........................................................................66
Referencing a variable.........................................................................................67
Activity: Referencing variable values................................................................68
Using arrays..................................................................................................................70
Defining an array ................................................................................................70
Declaring an array ...............................................................................................70
Assigning values to an array..............................................................................71
Activity: Building and referencing an array.....................................................72
Activity: Referencing an array between formulas...........................................73
Quiz: Using variables and arrays..............................................................................74
Lesson summary .........................................................................................................75

Lesson 5

Creating Report Templates


Lesson introduction.....................................................................................................77
Applying report templates.........................................................................................78
Applying a predefined template........................................................................78
Activity: Using a predefined template..............................................................79
Using an existing report as a template .............................................................80
Activity: Using an existing report as a template..............................................80
Building a template without a data source..............................................................82
Creating a template without a data source ......................................................82
Activity: Building a template without a data source......................................83
Removing a template...................................................................................................85
Removing an applied template..........................................................................85
Activity: Removing an applied template..........................................................85

Table of ContentsLearners Guide

For internal use by CSC only

Distributing personalized content.....................................................................50


Creating Dynamic Recipient Data Providers (DRDPs) .................................51
DRDP Design considerations ............................................................................52
Personalization with DRDPs .............................................................................53
Active Directory recipients ................................................................................55
Creating Report Alerts for delivery rules.........................................................56
Indexing saved data.............................................................................................57
Using the Saved Data Indexes dialog box........................................................58
To index saved data.............................................................................................59
Quiz: Managing reports .............................................................................................60
Lesson summary .........................................................................................................61

Quiz: Using report templates ....................................................................................86


Lesson summary..........................................................................................................87

Lesson 6

Building Parameterized Reports

For internal use by CSC only

vi

Business Reporting SolutionsLearners Guide

For internal use by CSC only

Lesson introduction.....................................................................................................89
Defining and creating parameters.............................................................................90
Common uses of parameters..............................................................................90
Creating a parameter with a static prompt......................................................90
Creating a parameter with a dynamic prompt................................................91
Using a parameter in record selection...............................................................92
Responding to a parameter.................................................................................94
Responding to a parameter when refreshing data..........................................95
Using the Parameter Panel..................................................................................96
Creating a saved-data record filter using parameter fields...........................98
Using optional parameters..................................................................................98
Populating prompt values from a database.....................................................99
Using a list of values..........................................................................................101
Sharing common lists of values within a report............................................101
Using separate value and description fields..................................................102
Using command objects as list-of-values data sources ................................102
Null handling......................................................................................................102
Displaying a single-value parameter on a report..........................................104
Describing values and sorting..........................................................................105
Activity: Building a dynamic cascading parameter with optional
prompts................................................................................................................105
Building a report with multiple parameters..........................................................107
Specifying single or ranges of values..............................................................107
Creating a report with multiple prompting values.......................................108
Activity: Building a report with multiple parameters..................................108
Applying conditional formatting using parameter fields............................109
Activity: Displaying a multiple value parameter on a report.....................110
Deleting a parameter from a report.................................................................111
Using edit masks and descriptions.........................................................................113
Using an edit mask.............................................................................................113
Using a description............................................................................................114
Activity: Using an edit mask............................................................................114
Creating date range parameters..............................................................................116
Date and DateTime parameters ......................................................................116
Creating a date range parameter.....................................................................116
Activity: Creating and displaying a date range parameter..........................117
Grouping using parameters.....................................................................................118
Creating a report with dynamic grouping ....................................................118
Activity: Defining grouping using a parameter............................................118
Quiz: Building parameterized reports ...................................................................120

Lesson summary .......................................................................................................121

Lesson 7
Lesson introduction...................................................................................................123
Building a basic crosstab...........................................................................................124
Defining crosstabs..............................................................................................124
Creating a crosstab.............................................................................................125
Creating a crosstab object in an existing report.............................................126
Activity: Building a basic crosstab object........................................................132
Formatting a crosstab................................................................................................134
Using the crosstab formatting options............................................................134
Creating a customized crosstab style..............................................................137
Activity: Formatting a crosstab........................................................................139
Conditionally formatting a crosstab ...............................................................140
Adding a chart to a crosstab report ................................................................141
Activity: Highlighting and charting crosstab data........................................142
Adding Calculated Members...........................................................................143
Activity: Adding Calculated Members to a crosstab....................................144
Quiz: Summarizing data with crosstabs ................................................................147
Lesson summary........................................................................................................148

Lesson 8

Using Report Sections


Lesson introduction...................................................................................................149
Using sections.............................................................................................................150
Using the Section Expert options conditionally.............................................150
Creating new sections........................................................................................151
Deleting sections.................................................................................................153
Moving sections..................................................................................................153
Merging sections................................................................................................154
Creating page breaks.........................................................................................155
Activity: Creating and merging sections........................................................156
Activity: Applying conditional formatting to sections.................................157
Using group-related functions to format sections................................................159
Using group-related functions.........................................................................159
Activity: Using group-related functions to format sections.........................159
Using section underlay.............................................................................................162
Using section underlay in a report..................................................................162
Activity: Using underlay in a report...............................................................164
Formatting with multiple columns.........................................................................165
Using multiple-column formatting..................................................................165
Activity: Formatting using multiple columns................................................166
Quiz: Using report sections......................................................................................167

Table of ContentsLearners Guide

vii

For internal use by CSC only

For internal use by CSC only

Summarizing Data with Crosstabs

Lesson summary........................................................................................................168

Lesson 9

Building Specialized Reports

For internal use by CSC only

viii

Business Reporting SolutionsLearners Guide

For internal use by CSC only

Lesson introduction...................................................................................................169
Using the Running Total Expert..............................................................................170
Creating a running total field using the Running Total Expert..................170
Placing a running total field in a report..........................................................171
Choosing evaluation and reset options...........................................................172
Creating conditional running totals................................................................173
Activity: Using the Running Total Expert......................................................174
Creating a form letter................................................................................................176
Planning and creating a form letter.................................................................176
Using conditional messaging in a form letter................................................177
Adding a picture to a form letter.....................................................................178
Activity: Creating a form letter........................................................................178
Adding a hyperlink to a report................................................................................181
Creating a hyperlink field.................................................................................181
Activity: Adding a hyperlink to a report........................................................182
Using dynamic graphic locations............................................................................184
Inserting a linked object....................................................................................184
Working with linked objects.............................................................................185
Activity: Using dynamic graphic locations....................................................186
Building a report with alerts....................................................................................187
Creating a Report Alert.....................................................................................187
Editing a Report Alert .......................................................................................189
Deleting a Report Alert......................................................................................189
Viewing Report Alerts.......................................................................................189
Referencing Report Alerts in formulas...........................................................190
Activity: Building a report with Report Alerts..............................................191
Building a top N report.............................................................................................192
Creating a top or bottom N report...................................................................192
Creating a parameterized top or bottom N report........................................194
Activity: What information will you see?.......................................................194
Activity: Building a top N report.....................................................................195
Integrating Flash........................................................................................................197
Integrating Shockwave Flash (SWF) objects...................................................197
Adding an Xcelsius SWF object to a report....................................................198
Using data binding to bind an Xcelsius SWF object to a report..................198
Activity: Integrating an Xcelsius Flash file into a Crystal report................199
Quiz: Building specialized reports..........................................................................201
Lesson summary........................................................................................................202

Quiz: Using the repository and repository data sources ....................................205


Activity: Defining string functions and operators ...............................................206
Activity: Defining date and time functions and operators .................................207
Quiz: Creating formulas ..........................................................................................208
Quiz: Managing reports ...........................................................................................209
Quiz: Using variables and arrays............................................................................210
Quiz: Using report templates ..................................................................................211
Quiz: Building parameterized reports ...................................................................212
Quiz: Summarizing data with crosstabs ................................................................213
Quiz: Using report sections......................................................................................214
Quiz: Building specialized reports..........................................................................215

Table of ContentsLearners Guide

ix

For internal use by CSC only

For internal use by CSC only

Answer Key

For internal use by CSC only

For internal use by CSC only

Business Reporting SolutionsLearners Guide

Introductions, Course Overview...........................................30 minutes


Lesson 1

Using the Repository and Repository Data Sources..............1 hour


Using the Repository
Creating a report from a repository data source
Lesson 2

Creating Formulas........................................................................1.5 hours


Using functions and operators
Defining control structures in Crystal syntax
Lesson 3

Managing Reports.....................................................................30 minutes


Using the Workbench
Publishing to BusinessObjects Enterprise
Lesson 4

Using Variables and Arrays.......................................................1.5 hours


Using variables
Using arrays
Lesson 5

Creating Report Templates..............................................................1 hour


Applying report templates
Building a template without a data source
Removing a template
Lesson 6

Building Parameterized Reports..............................................1.5 hours

Defining and creating parameters


Building a report with multiple parameters
Using edit masks and descriptions
Creating date range parameters

AgendaLearners Guide

xi

For internal use by CSC only

For internal use by CSC only

Business Reporting Solutions

Grouping using parameters


Lesson 7

Summarizing Data with Crosstabs...............................................1 hour


Building a basic crosstab
Formatting a crosstab
Lesson 8
For internal use by CSC only

Using sections
Using group-related functions to format sections
Using section underlay
Formatting with multiple columns

Lesson 9

Building Specialized Reports...................................................2.5 hours

xii

Using the Running Total Expert


Creating a form letter
Adding a hyperlink to a report
Using dynamic graphic locations
Building a report with alerts
Building a top N report
Integrating Flash

Business Reporting SolutionsLearners Guide

For internal use by CSC only

Using Report Sections......................................................................1 hour

About this Course


Course introduction
This section explains the conventions used in the course and in this training guide.

For internal use by CSC only

For internal use by CSC only

About this CourseLearners Guide

xiii

Course description
Crystal Reports 2008 is a powerful, dynamic, actionable reporting solution that helps you
design, explore, visualize, and deliver reports via the web or embedded in enterprise
applications. This course is designed to give you comprehensive skills and in-depth knowledge
to plan and create reports that will help you analyze and interpret information.

For internal use by CSC only

Course audience
The target audience for this course is report designers who are responsible for creating and
distributing reports and have completed Crystal Reports 2008: Report Design I - Fundamentals
of Report Design.

Prerequisites
You should have completed Crystal Reports 2008: Report Design I - Fundamentals of Report
Design. If you have taken a previous version of Report Design I - Fundamentals of Report
Design, then you should have completed Crystal Reports 2008: Quickstart.
To be successful, you must have working knowledge of:
Windows conventions
Basic database concepts
Experience using a web browser

Additional education
To increase your skill level and knowledge of Crystal Reports, the following courses are
recommended:
Crystal Reports 2008: Report Design III - Report Processing Strategies
Crystal Reports 2008: Report Design IV - Optimizing Report Data

Level, delivery, and duration


This core instructor-led offering is a two-day course.

Applicable certifications and designations


This is a recommended course in the Business Objects Certified Professional - Crystal Reports
certification.

xiv

Business Reporting SolutionsLearners Guide

For internal use by CSC only

As a business benefit, you will be able to increase your understanding of formulas, variables,
arrays, templates, parameters, summaries, and sections, which will help you make more effective
report design decisions and create more efficient reports.

For internal use by CSC only

For internal use by CSC only

Course success factors


Your learning experience will be enhanced by:

Activities that build on the life experiences of the learner


Discussion that connects the training to real working environments
Learners and instructor working as a team
Active participation by all learners

Course setup
Refer to the setup guide for details on hardware, software, and course-specific requirements.

Course materials
The materials included with the course materials are:
Name card
Learners Guide
The Learners Guide contains an agenda, learner materials, and practice activities.
The Learners Guide is designed to assist students who attend the classroom-based course
and outlines what learners can expect to achieve by participating in this course.
Evaluation form
At the conclusion of this course, you will receive an electronic feedback form as part of our
evaluation process. Provide feedback on the course content, instructor, and facility. Your
comments will assist us to improve future courses.

About this CourseLearners Guide

xv

Additional resources include:


Sample files
The sample files can include required files for the course activities and/or supplemental
content to the training guide.
Online Help

Learning process
Learning is an interactive process between the learners and the instructor. By facilitating a
cooperative environment, the instructor guides the learners through the learning framework.

Introduction
Why am I here? Whats in it for me?
The learners will be clear about what they are getting out of each lesson.

Objectives
How do I achieve the outcome?
The learners will assimilate new concepts and how to apply the ideas presented in the lesson.
This step sets the groundwork for practice.

Practice
How do I do it?
The learners will demonstrate their knowledge as well as their hands-on skills through the
activities.

Review
How did I do?
The learners will have an opportunity to review what they have learned during the lesson.
Review reinforces why it is important to learn particular concepts or skills.

Summary
Where have I been and where am I going?
The summary acts as a recap of the learning objectives and as a transition to the next section.

xvi

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Retrieve information and find answers to questions using the online and/or users guide
that are included with the product.

Lesson 1

Using the Repository and Repository Data Sources


Lesson introduction

For internal use by CSC only

For internal use by CSC only

The BusinessObjects Enterprise Repository is the central location for you to store and manage
your report objects.
After completing this lesson, you will be able to:
Use the repository
Create a report from a repository data source

Using the Repository and Repository Data SourcesLearners Guide

Using the Repository


The repository is a component of BusinessObjects Enterprise. Report designers can create objects
and store them in the repository for reuse on multiple reports.

Define the repository


Add folders to the repository
Add objects to the repository
Update repository objects
Delete repository objects
Define an SQL Command
Create a report from a BusinessObjects universe
Change a report's universe data source location

The repository
The repository is the central location for you to store and manage your report objects. These
objects are then accessible to users and report developers for use in new reports that can be
distributed throughout your company.
Physically, the repository is a database that stores supported object types. These types include:
Text objects
Bitmaps
Custom functions
SQL commands (queries)
List of values
Universes
Tip: Hover your mouses cursor over any object in the Repository Explorer to see a tooltip. Tooltips
include author and description information for text objects and bitmaps. Tooltips also include the
complete text of the SQL statement.

The Repository Explorer might appear in a docked position in the Report Designer depending
on where it was when you last used Crystal Reports. You can drag it where you like, or dock
it elsewhere. The Repository Explorer can also be docked as a tab, similar to the Design tab,
along with the Report Explorer.

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

After completing this unit, you will be able to:

For internal use by CSC only

The toolbar in the Repository Explorer provides buttons with tooltips. These buttons let you
expand subfolders, add new folders, search for items, and perform other tasks:
Change view settings
Use this option to open the View Settings dialog box. Use this dialog box to limit the type
of repository items displayed in the Repository Explorer. You can also select options to sort
multiple items by name or by type.
Advanced filtering
Use this option to display filtering options at the bottom of the Repository Explorer. Use
these filters to find specific items by words from the Name or Author fields in the Add Item
dialog box.
Note: Text entered in the filtering fields of this option is not case sensitive.
Delete the item/folder
Use this option to permanently remove the selected item or folder from the repository. When
you delete a folder, you delete all the items it contains.
Insert a new folder
Use this option to add a new folder to the repository.
Logon (Logoff) Server
This button changes to Logoff Server when you are logged into the repository. Use this
option to log on or off the server.

To connect to the repository in the Repository Explorer


1. Click the Repository Explorer icon on the Standard toolbar.
Tip: Another way to do this is to select the Repository Explorer command from the View
menu.

Using the Repository and Repository Data SourcesLearners Guide

For internal use by CSC only

The repository is contained in BusinessObjects Enterprise. You must install BusinessObjects


Enterprise to access the repository.

2. Click the Logon Server button.


Note: If you are already logged on, you may skip to step 4.
3. Type your user name and password. Click OK.
The Repository Explorer appears.
4. Click the plus sign (+) to expand the folder and show all subentries.

For internal use by CSC only

You can organize the contents of the repository by creating folders and subfolders in its tree
view.

To add a folder to the repository


1. In the Repository Explorer, right-click the Repository Items folder and then select New
Folder from the shortcut menu.
Tip: As an alternate to the above method, select the Repository Items folder and then click
the Insert a new folder button on the Repository Explorers toolbar.
A new folder is added to the bottom of the repository tree if repository items are sorted by
type. (If your repository items are sorted by name, the new folder is added alphabetically
with the default name New Folder.)
2. Right-click the New Folder and select Rename from the shortcut menu. Type in the new
name for the folder, and press Enter.
3. To add a subfolder, right-click your new folder and select New Folder from the shortcut
menu. Name your new subfolder and press Enter.

Activity: Adding folders to the repository


Objective
Log into BusinessObjects Enterprise, access the repository, and add a folder that will store
objects for use in future reports.

Instructions
1. Log into the BusinessObjects Enterprise using the Logon Server button in the Repository
Explorer.
2. Create folder named Report Design II in the Repository Items folder of the Repository
Explorer.

Business Reporting SolutionsLearners Guide

For internal use by CSC only

Adding folders to the repository

Adding objects to the repository


You can add text objects and bitmap images to the repository by dragging them from your
report to the appropriate repository folder. A dialog box appears so you can add identifying
information about the object.

Once report items are in the repository, they can be shared between many reports. Each person
who uses Crystal Reports can connect to the repository and choose items to add to a report.
When you add an object to the repository, that object becomes "connected" to the repository.
As long as an object remains connected, you can update any report that uses that object with
the latest version in the repository.

To add a text object or bitmap image


1. Select a text object or bitmap image in your report and click Add to Repository from the
shortcut menu.
The Add Item dialog box appears.
Notice that because you did not drag the object to a specific repository folder, this dialog
box contains an area to select a location from.
2. In the Name field, create a name for your object or image.
Note: You cannot use these characters in your object's name: # " { } ; /
3. In the Location area, select a repository folder, and then click OK.
You'll see that your text object or bitmap image has been added to the selected folder.
If you try to edit any of the objects you add to the repository, youll see that you cant make changes.
The objects are in read-only mode. This is true of any object that is stored in the repository. As long
as it is connected to the repository it cant be changed in the report. If you right-click the object in
the report and choose Disconnect from Repository from the shortcut menu, the item disconnects
from the repository and becomes editable. If you want other reports to be updated with the edited
report object, you must add them back to the repository.

Activity: Using objects in the repository


Objective
Use objects from the repository on a report.

Instructions
1. Open Accessing the repository-1.rpt.

Using the Repository and Repository Data SourcesLearners Guide

For internal use by CSC only

For internal use by CSC only

Custom functions are added to the repository through the Formula Workshop and commands
are added through the Database Expert.

2. The Copyright text object is located in the Text Objects folder of the Repository Items
Folder. Insert the Copyright text object into the page footer and center it on the page.
3. Add a text box below the chart in the Report Header. Type Report Designed for Marketing
Department - NY in the text box.
4. Create a folder in the repository called Custom Objects.
5. Add the marketing text box to the new folder calling it Marketing Department. Fill in the
name as Administrator and use any description.
For internal use by CSC only

Updating repository objects


Repository objects used in a report and connected to the repository can be updated automatically
when opening the report in Crystal Reports. There are two ways to update repository objects;
globally or individually.
When you update globally each time a report is opened the repository objects are updated.
Note: Objects that are used in a report but are disconnected from the repository are not automatically
updated when the report is opened.

To set the update option globally


1. On the File menu, click Options.
The Options dialog box appears.
2. Click the Reporting tab.
3. Select the Update Connected Repository Objects on Open check box.
4. Click OK.
When you update individually the global option for updating objects is not activated and
instead reports are updated on an individual basis.

To update repository objects individually


1. On the File menu, click Open.
2. Browse to the location of the report to be opened.
3. In the Open dialog box select the Update Repository Objects option.
4. Click OK.

Deleting items from the repository


Any object you store in the repository can be deleted from that repository without removing
it from the reports that use it. Once you remove an object from the repository, it is removed
for all users.

Business Reporting SolutionsLearners Guide

For internal use by CSC only

6. Save the report as Using objects in the repository.rpt.

Note: When you delete an object from the repository, it appears to remain connected in the reports
that use it. When you try to update repository objects for those reports, a warning message is shown
in the Missing Repository Items dialog box so you can quickly identify the object. Use the Report
Explorer dialog box to find the object in the report, then you can disconnect it.
Note: If you have deleted an object from the repository, creating a new object with the same name
and adding it back to the repository does not relink that object to your reports. Each repository
object has a unique ID; linking is not done by name.

For internal use by CSC only

1. Click the Repository Explorer button on the Standard toolbar.


Tip: Another way to do this is to click the Repository Explorer option under the View menu.
2. In the appropriate folder, select the object you want to remove and press the Delete key.
You are asked to confirm the deletion.
You can also delete a repository object by right-clicking it and selecting Delete from the
shortcut menu.
3. Click the Yes button.
The object is removed from the repository.

Activity: Modifying objects and updating reports


Objective
Modify and update repository objects on a report.

Instructions
1. Open Repository-2.rpt.
2. Add the copyright text object from the repository to the report in the page footer.
Note: The copyright text object can be found in Repository items Text Objects.
3. Ensure you select the option to update connected repository objects on opening.
Tip: To change options, go to: File Options Reporting Update Connected
Repository Objects on Open.
4. Save the report as Repository-added item.rpt and close the report.
5. Open the report Using objects in the repository.rpt from the previous activity.
6. Disconnect the Copyright text object from the repository.
7. Change the Copyright text object to 2008 and add the Copyright text object back to the
repository using its original name.

Using the Repository and Repository Data SourcesLearners Guide

For internal use by CSC only

To delete an object from the repository

8. Save the report as Modifying objects and updating reports.rpt and close the report.
9. Open the Repository-added item.rpt.
10.What changes do you notice?
11.Re-save Repository-added item.rpt.
12.Delete the Copyright text item from the repository and close Repository-added item.rpt
and Crystal Reports.

Note: You may get the Log on server screen for the Repository Explorer when you restart
Crystal Reports.
Note: A display message informs you that it could not find the deleted repository object.
Does the report still work?
Your report should look similar to this:

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

13.Restart Crystal Reports and open Modifying objects and updating reports.rpt.

Creating a report from a repository data source


In addition to objects that can be placed on the report, the repository can store SQL Commands
as objects that define a subset of data from the database.
After completing this unit, you will be able to:

SQL Commands
Using SQL Commands in Crystal Reports is similar to using stored procedures. Stored
procedures, written and stored in the database, can increase the efficiency with which data is
brought to the report. SQL Commands do the same. While stored procedures are more efficient
because they are precompiled, SQL Commands are more efficient because they return a subset
of data. As well, some report requirements, such as grouping and summing, can be performed
on the data before it arrives at the report.
An SQL Command is different than a stored procedure because it can be written within Crystal
Reports so the report writer does not need write access to the reporting database.
If the database you are using supports a query language such as SQL, you can write your own
commands which are represented in Crystal Reports as a Table object. This allows database
users complete control of the data processing that gets pushed down to the database server. A
user who has experience with databases and the SQL language can write a highly optimized
command that can considerably reduce the data set size returned from the server.
Write your own command by using the Add Command node in the Database Expert to create
a virtual table that represents the results of processing the command. Once the command is
created, you can store it in the repository so it can be shared between many users.
Note: Some of the Crystal Reports native database drivers do not support the Add Command
feature:

DB2 Server
Sybase Server
Informix Online Server

Creating a report from a BusinessObjects universe


Crystal reports based on BusinessObjects universes (the semantic layer for Business Objects
query-and-analysis tools such as Web Intelligence) support universe run-time security and
union queries. These enhancements allow for most features defined in the universe to be
supported when you report off that universe in Crystal Reports.
In Crystal Reports, access the BusinessObjects Query Panel through the Database Expert.
Once you have selected Universes from the Create New Connection node, you are prompted

Using the Repository and Repository Data SourcesLearners Guide

For internal use by CSC only

For internal use by CSC only

Define an SQL Command


Create a report from a BusinessObjects universe
Change a report's universe data source location

to log onto BusinessObjects Enterprise, after which you can select a universe and design your
query against that universe selecting all desired fields to be made available to the Field Explorer.

To connect to a universe
1. In Crystal Reports, on the File menu, click New, and then click Blank Report.
2. In the Database Expert, double-click Create New Connection.

4. Log onto BusinessObjects Enterprise if you have not done so already.


5. Select the universe that you want to base your query on, and then click Open.
The Business Objects Query Panel appears.

Defining the data selection for a query


You build queries in the Query Panel by using objects in a Business Objects universe. The
objects in the universe are a graphical representation of the information available in a database.
The objects in the universe are mapped to the table columns and rows in the database.
The Query Panel is divided into several panes:
The pane on the left shows a tree view of the objects that your universe contains. You cannot
add new objects or edit existing objects in the Query Panel.
Note: You can see all available objects in this pane by selecting All objects. If you want to
see how objects relate to each other, select Hierarchies. This option provides you with a
visual representation of the hierarchical structure of objects if such a structure is present in
the universe.
The Result Objects pane is where you place the objects that you want as part of your query.

To build a simple query


1. In the Query Name field, enter a name for your query.
Note: Crystal Reports uses the query name as the name of the SQL Command that it creates
for your report. Once you have created your query in the Query Panel, the query name
appears in the Available Data Sources and Selected Tables areas of the Database Expert.
2. Select an object in the left-hand pane and double-click it or drag it into the Result Objects
pane.
Objects that appear in the Result Objects pane become fields that you report on in your
Crystal report.
3. Repeat the previous step for each object that you want to include in the query.
4. Select an object in the left-hand pane, or in the Result Objects pane, and drag it into the
Query Filters pane.

10

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

3. Double-click Universes.

Note: Add filters to the Query Filters pane to restrict the data your query returns based on
the object that you selected. Filtering limits the data that a user can see and reduces the
runtime of queries.
5. Click OK.
6. If your query contains prompts, select your prompt value(s) in the Enter Parameter Values
dialog box.

For internal use by CSC only

7. If your data source is secure, use the connection dialog box to log onto the database that
your universe uses.

Setting data source location


Report designers frequently build reports in a test environment and then move them to a
production environment when they are ready. When the report is published from a test
environment to a production environment, the location of the data source (in this case, a
universe) needs to be reset in order to have it report on the production universe. The Set
Datasource Location feature makes it possible to create a query using one universe and then
apply it to a new universe.

To set the universe location


1. From the Database menu, select Set Datasource Location.
2. In the Replace with tree, locate the Universes node and double-click Change to New
Universe.
3. In the BusinessObjects Enterprise Explorer, select the appropriate universe.
You see the Business Objects Query Panel showing an identical query to the one you
created.
4. Click OK.
A new query has been added.
5. Select the new query and click Update.
6. Click Close on the Set Datasource Location window.
7. Click Refresh to refresh the report using the new universe.

Activity: Creating a report from a repository data source


Objectives
Use a connection in the repository to create a new Crystal report.

Using the Repository and Repository Data SourcesLearners Guide

11

For internal use by CSC only

Note: For information about using the Enter Parameter Values dialog box, search for the
dialog box by name in the Crystal Reports Online Help.

Create a report off a universe.


Change the universe location.
You are a BusinessObjects Enterprise user, creating Crystal reports based on universes. You
create reports in your test environment and then move them to your production environment
when they are ready.

For the purposes of this activity, the Xtreme1 universe is your test environment and the Xtreme2
universe is your production environment.

Instructions
1. Create a new blank report.
2. In the Database Expert, create a connection to the Xtreme1 universe.
Enter the required BusinessObjects Enterprise logon information.
3. Select the Customer Name, Last Year's Sales, Country, and Region objects for your query.
4. In the Database Expert dialog box, move Xtreme1_query to Selected Tables and click OK.
5. Add all the fields from Xtreme1_query to the Details section of the report.
6. Preview the report.
7. View the Xtreme1_query properties in Database Query Panel to verify that the Xtreme1
test environment is the query's data source.
8. Change the data source location for the report to the production environment Xtreme2
universe.
9. Refresh the report.
The report should look the same as it did before you changed the data source.
10.View the query properties in the Query Panel to verify that the report uses the Xtreme2
universe as a data source.
11.Save the report as Creating a report from a repository data source.rpt.

12

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

When you publish a report to the production environment, you need to perform a Set Location
in order for it to report on the production universe.

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

Using the Repository and Repository Data SourcesLearners Guide

13

Quiz_ Using the repository and repository data


sources
Quiz: Using the repository and repository data sources
2. Repository tooltips include

and

information for text objects and bitmaps.

3. True or False. If an item or folder is deleted from the repository it is permanently removed.
4. When saving text object or bitmap images to the repository, you can use all the following
characters in the object's name:
A) $ * " ! @
B) . # ^ & ~
C) % ! * ^ )
D) ; @ ~ $ *
5. True or False. Any object stored in the repository can be deleted but those objects must also
be deleted from the report.
6. True or False. All Crystal Reports native drivers support the Add Command feature.
7. Custom functions can be added to the repository through the

8. True or False. The Set Datasource Location feature makes it possible to create a query based
on one universe and then apply it to a new universe.

14

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

1. What types of objects can be stored in the repository?

Lesson summary
After completing this lesson, you are now able to:
Use the repository
Create a report from a repository data source

For internal use by CSC only

For internal use by CSC only

Using the Repository and Repository Data SourcesLearners Guide

15

For internal use by CSC only

For internal use by CSC only

16

Business Reporting SolutionsLearners Guide

Lesson 2

Creating Formulas
Lesson introduction
Crystal Reports offers powerful formula capabilities to expand the functionality of your report.
For internal use by CSC only

For internal use by CSC only

After completing this lesson, you will be able to:


Use functions and operators
Define control structures available in Crystal syntax

Creating FormulasLearners Guide

17

Using functions and operators


Crystal Reports comes with a number of built-in functions and operators. This unit covers some
of these functions and operators and their uses, as well as ways to expand your knowledge
about the many functions and operators that Crystal Reports includes.

Define functions and operators


Use help when creating formulas
Use string functions and operators
Use nested string functions
Use number functions
Use date and time functions
Use arithmetic operators
Use Boolean operators

Defining functions and operators


Functions are built-in procedures or subroutines used to evaluate, make calculations on, or
transform data.
When you specify a function, the program performs the set of operations built into the function
without you having to specify each operation separately. A function is a kind of shorthand that
makes it easier and less time consuming for you to create reports.
Operators are special symbols or words that describe an operation or an action to take place
between two or more values. Operators are used in formulas. The program reads the operators
in a formula and performs the actions specified.
Functions return a value, but operators do not.

Using help when creating formulas


With all the functions and operators available in Crystal Reports, it may be challenging to
accurately recall the syntax and names of those functions and operators. Fortunately, online
Help has a list of all the functions and operators, the syntax required when using them, as well
as examples of where they might be used. Using the index tab of the Help function will help
you find functions and operators more efficiently.

Auto-Complete in the Formula Editor


When entering the name of a function or operator in the Formula Editor, type the first few
letters and then CTRL + Spacebar. Crystal Reports compares the characters typed to its keyword
list. If there is only one match, it completes the entry for you. If there are multiple matches, you
can select the correct entry from a list box.

18

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

After completing this unit, you will be able to:

For example, try typing AV then CTRL + Spacebar. Average is the only function or operator
that matches, thus Crystal Reports completes the entry. However, if you type DATE then CTRL
+ Spacebar, it displays a list of all the functions that begin with those characters.
For a list of more keyboard shortcuts, consult online Help topic Formula Editor Key Controls
(via the Index tab).

1. Enter Help by pressing F1, selecting Crystal Reports Help from the Help menu, or clicking
the ? button on the Formula Editor toolbar.
2. Select the Index tab.
3. Type in the keywords Functions or Operators.
4. Scroll through the list of functions or operators to the name of the function or operator youd
like to examine.
5. Click the desired item.
The item is now highlighted.
6. Click the Display button on the bottom left of the window.
Alternatively, double-click the desired item.
Descriptive information about the function or operator is displayed in the right pane of the
Help window.

Using string functions and operators


String functions are used for the evaluation, manipulation and conversion of text strings.
Two examples of string functions are:
Length
Trim
Length(str)
Length returns the number of characters in a text string that you enter into the formula, or in

a text string stored as a value in a data field.


You must enclose text strings in either double or single quotation marks (" " or ' '). The character
count includes any blank spaces in the string.
Use this function any time you have a manipulation, comparison, or calculation that is dependent
on the length of a text string.
The following examples are applicable to both Basic syntax and Crystal syntax:
Functions
Length("Account")

Creating FormulasLearners Guide

Result

19

For internal use by CSC only

For internal use by CSC only

To find what functions and operators are available

Functions

Result

Length(Text_String)

11

Length("_Center_")

The Trim function removes leading and trailing spaces from string arguments.
Use this function any time there are leading and/or trailing blanks in a text object that may
interfere with an alignment of text strings, a character count, or with a calculation (if the string
is eventually converted to a number).
The following example is applicable to both Basic syntax and Crystal syntax:
Functions

Result

abcde

Trim(" abcde ")

String operators
You can use string operators to concatenate (join) text strings, to extract substrings from text
strings, or to test for the presence of substrings in text strings.
Operators are case-sensitive. For example, ABC is not equal to abc. Nor is abc in the
string ABCDEF.
Concatenate operator (x+y) and Concatenate(x&y)
Subscript (y[x])
Concatenate (x+y)

and Concatenate

(x&y)

Concatenate (x+y) and Concatenate (x&y) are synonymous if both operands x and y are

strings.
Concatenate (x+y)

Concatenates the values of x and y, and returns the result as a string; x and y must both be
strings.
The following examples are applicable to both Basic syntax and Crystal syntax:
"Bread" + " and " + "butter"

Returns Bread and butter.


"Your customer name is " + ({Customer.Customer Name}) + " and your company
contact person is " +
({customer.CONTACT FIRST NAME}) + "."

Returns "Your customer name is Bicicletas Buenos Aires and your company contact person
is Carlos".

20

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Trim(Str)

Concatenate (x&y)

Concatenates the values of x and y, and returns the result as a string; x and y can be different
data types Number, Boolean, Currency, Date, Time, DateTime, and String.
The following examples are applicable to both Crystal syntax and Basic syntax:
10 & 20

Returns the string 10.0000020.00000 where the number formatting for this formula field
specifies five decimal places.
Returns the string TrueFalse.
"The meeting is " & #Nov 15, 1999#

Returns the string The meeting is 11/15/99 12:00:00 AM.


Subscript x[y]

Subscript extracts one or more characters from a text string or extracts an element from an
array.
The subscript ranges are 1-based; they start at 1 rather than 0.
Subscript

Behavior

x[y]

Extracts the y element from string x or


array x

x[y to z]

Extracts the y to z range of elements


from string x or array x

LNAME [1]

Crystal syntax that returns S, where


LNAME =Smith

Postal [6]

Crystal syntax that returns V, where


Postal Code = T5A 9V2 (the space
between A and 9 counts as an element)

{customer.POSTAL CODE} [5 to 7]

Crystal syntax that returns 9V2, where


Postal Code = T5A 9V2

{file.ITEMNUMBER} [4 to 5]

Creating FormulasLearners Guide

Crystal syntax that returns 40, where


ItemNumber is A1/4020/B10

21

For internal use by CSC only

For internal use by CSC only

True & False

Activity: Defining string functions and operators


Objective
Use the help system to match the string functions and operators with their definitions.

Instructions
1. Using the Crystal Reports Help system, match the descriptions to the correct items.
For internal use by CSC only

Length

Description

A. Reverses the True or False value.

Subscript(x[y]) B. Use this function to convert a Boolean, Number, Currency, Date,

Time, or DateTime value to a text string to appear as text in your


report, form letters, or comments.

22

Trim

C. Returns a String in which a specified substring has been replaced


with another substring a specified number of times.

Right

D. Returns the number of characters in a text string that you enter


into the formula, or in a text string stored as a value in a data field.

Not

E. Prints a string or values in a text string in a predetermined format.

Replace

F. Evaluates the field specified in the current record and returns TRUE
if the field contains a null value.

x&y

G. Removes leading and trailing spaces from string arguments.

Picture

H. Extracts the y element from string x or array x.

Instr

I. Extracts the given number of text characters from the left side of
the specified string.

Left

J. Extracts the given number of text characters from the right side of
the specified string.

IsNull

K. Returns the position of the first occurrence of one string within


another.

ToText

L. Concatenates the values of x and y, and returns the result as a


string.

Business Reporting SolutionsLearners Guide

For internal use by CSC only

Item

Using nested string functions and operators


When you build complex formulas, you often need to use functions. Sometimes you may need
to use functions within functions, or nested functions.
Functions are nested when one functions argument is the result of another function.

The Left() function is passed a string to be manipulated as the first argument. The second
argument is a number indicating how many characters starting from the left of the string need
to be extracted.
The ToText() function can take different types of fields and convert them to strings. In this
case, there is one argument that is a number.
The formula to extract the left-most digit from the order number is as follows:
Left(ToText({table.order_number}),1)

If you pass the order number 5269, the result is:


Left(ToText(5269),1)

The number 5 is returned.

Activity: Using string functions and operators


Objective
Use functions and operators in a report.

Instructions
1. Create a new report using the Employee table from the Xtreme Sample Database.
2. Create a formula named Name that displays the first initial and last name of each employee.
3. Create a formula named Account that concatenates the last three digits of the extension
field with the fifth through eighth digits of the SSN field.
4. Display the Emergency Contact Phone in a specific format:
If the phone number is 10 digits then format it as (555) 555-5555
If the phone number is not 10 digits then format it as 55-555-5555
5. Display the first sentence of the notes field. Make sure there are no leading or trailing spaces.
Make sure the entire sentence displays and doesnt stop at an abbreviation.
6. Save the report as Using string functions and operators.rpt.
The report should look like this:

Creating FormulasLearners Guide

23

For internal use by CSC only

For internal use by CSC only

For example, you can nest the ToText() function inside the Left() function to help return the
first digit of the order number.

For internal use by CSC only

Numeric functions evaluate the value of a number and manipulate the output based on the
value of that number. These functions are helpful when evaluating large groups of data. A
numeric function also allows you to identify patterns in data.
RoundUp, MRound, Ceiling, and Floor are all examples of numeric functions.

Tip: Remember to search Help if you are unsure of the functions and formulas.
RoundUp(x, num_digits)

RoundUp returns a number that has been rounded up. This function rounds up (away from
zero).
X is a real number to be rounded and num_digits is a whole number indicating the number
of decimal places to which x will be rounded.
MRound (x, multiple)

MRound returns a number that has been rounded to the multiple that you specify. This function
rounds up (away from zero) if the remainder of the division is greater than or equal to half
of the value of the multiple. X is a real number to be rounded to a multiple of the second
number. For example, MRound (127.75, 5) returns 130.
Ceiling(x, multiple)

Ceiling returns a number that has been rounded to the multiple that you specify. This
function rounds up (away from zero). Values are always rounded up when they are adjusted

24

Business Reporting SolutionsLearners Guide

For internal use by CSC only

Using numeric functions

away from zero (without regard to the sign of the value). If the number is an exact multiple
of the multiple, no rounding occurs.
X is a value to be rounded. Multiple is a multiple that you want to round the x value to. For
example, Ceiling (5,3) returns 6.

Floor returns a number that has been rounded to the multiple that you specify. This function
rounds down (away from zero). Values are always rounded down when they are adjusted
away from zero (without regard to the sign of the value). If the number is an exact multiple
of the multiple, no rounding occurs. X is a value to be rounded. Multiple is a multiple that
you want to round the x value to. For example, Floor (5,3) returns 3.

Activity: Using numeric functions


Objective
Use numeric functions to prepare a report that relies on data that has been rounded to a
preset multiple.

Instructions
1. Open the report Working with rounding formulas.rpt from the course resources.
Note: This report is based on Customer Orders. Currency fields show dollars and cents
and quantities range from zero to three.
2. Create a new formula called Estimated Order Amounts.
3. The Estimated Order Amounts formula should return a rounded dollar value for the
customers orders so that an estimate can be made of their future orders.
In the Estimated Order Amounts formula add the following syntax:
RoundUp({Orders.Order Amount}, 0)

4. Place the field on the report to the right of the Order Amount field.
5. Format the new field to have no .00 showing.

Creating FormulasLearners Guide

25

For internal use by CSC only

For internal use by CSC only

Floor(x, multiple)

6. Delete the Order Amount field and move the Estimated Order Amounts field next to the
Order ID field.
7. Create a new formula called Max Quantity to ship.
8. The Max Quantity to ship formula should return the maximum number of units to ship
given that all units ship in multiples of two.
In the Max Quantity to ship formula place the following syntax:
Ceiling({Orders_Detail.Quantity}, 2)

9. Place the Max Quantity to ship field on the report to the right of the Quantity field.
10.Format the new field to have no decimals showing.

26

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

The numbers have rounded to the dollar value and the cents are no longer visible.

11.Create a new formula called Min Quantity to Ship that evaluates the value of the Quantity
ordered and rounds down to the nearest even value using this syntax:
Floor({Orders_Detail.Quantity}, 2)

12.Place the field on the report to the right of the Max Quantity to ship field.
The first record (Order ID = 1) has a value of 1 in the Quantity field, and now has a
corresponding value of 0 in the Minimum Quantity to Ship field.

13.Format the new field as a number using the -1,123 style.


14.Delete the Quantity field and move the minimum and maximum formulas to the left.
A minimum and maximum quantity to ship have now been calculated based on the
customer's previous orders.
You now need a formula for estimating unit prices by rounding them up or down depending
on whether it is equal to or above xx.5, or below xx.5.
15.Create a new formula called Unit Price Estimates.
16.In the Unit Price Estimates formula place the following syntax:

Creating FormulasLearners Guide

27

For internal use by CSC only

For internal use by CSC only

Where the Quantity field shows an odd number, the Max Quantity to ship field has been
rounded up to the next even number.

MRound({Orders_Detail.Unit Price}, 1)

17.Place the Unit Price Estimates field on the report to the left of the Unit Price field.
18.Format the new field as a number using the $(1,123) style.
The rounding has shown where cents are below 50, it has been rounded down and where
they are equal to or above 50, have rounded up to the next dollar.
19.Delete the Unit Price field.
20.Save the report as Using numeric functions.rpt.
For internal use by CSC only

For internal use by CSC only

Your report should look similar to this:

Using date and time functions


Date functions allow you to convert numbers to dates (which you can then format to display
as you wish) and to convert dates to numbers.
Two examples of date and time functions are:
DateDiff
DateAdd
DateDiff
DateDiff returns a number of time intervals between two specified dates.
DateDiff (intervalType, startDateTime, endDateTime)

intervalType is a String expression that is the interval of time you use to calculate the
difference between startDateTime and endDateTime.

28

Business Reporting SolutionsLearners Guide

Description

yyyy

Year

Quarter (3-month period)

Month

Day of year

Day

Weekday

ww

Week (7-day period)

Hour

Minute

Second

For internal use by CSC only

For internal use by CSC only

IntervalType Value

startDateTime is the first DateTime value used in calculating the difference.


endDateTime is the second DateTime value used in calculating the difference.
The following examples are applicable to both Basic syntax and Crystal syntax:
Use DateDiff with the "d" or "y" interval type parameter to find the number of days between
two dates:
DateDiff ("d", #10/7/1999#, #10/10/1999#)

Returns 3.
DateAdd
DateAdd returns a DateTime value to which a specified number of time intervals have been

added.
DateAdd is used to add intervals of time to a DateTime. Its main feature is that the DateTime

returned is always valid. For example, DateAdd takes into account such factors as the number
of days in a month and leap years. If you want to add or subtract days to a DateTime, you could

Creating FormulasLearners Guide

29

use the addition and subtraction operators instead of DateAdd with the d parameter. However,
DateAdd also handles other types of intervals such as adding months or hours to a DateTime.
DateAdd (intervalType, nIntervals, startDateTime)

intervalType is a String expression specifying the interval of time to be added. Values can
be:
Description

yyyy

Year

Quarter (3-month period)

Month

Day of year

Day

Weekday

ww

Week (7-day period)

Hour

Minute

Second

nIntervals is a Number or numeric expression specifying the number of intervals to be


added. It can be positive (to get date-times in the future) or negative (to get date-times in
the past).
startDateTime is the DateTime value to which the intervals are to be added.
The following examples are applicable to both Basic syntax and Crystal syntax:
DateAdd("d", -32, #Sept 28, 1999#)

Returns the DateTime value for August 27, 1999.


DateAdd ("m", 1, #1/31/1996#)

Returns the DateTime value for February 29, 1996. Notice that DateAdd will not return the
invalid value February 31, 1996.

30

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

IntervalType Value

Activity: Defining date and time functions and operators


Objective
Use the help system to match the string function and operators with their definitions.

Instructions

Item

Description

DateDiff

A. Returns a number that specifies a given part of a given date.

DateAdd

B. Extracts the year from a Date and returns it as a number.

DatePart

C. Extracts the day from a Date or DateTime value and returns a


whole number.

DateSerial

D. Returns a number of time intervals between two specified dates.

IsDate

E. Returns a DateTime value to which a specified number of time


intervals have been added.

Date

F. Returns TRUE if the given String or Number value can be


converted to a valid Date.

Year

G. A number, string or DateTime value can be passed in as an


argument, but a date value always gets returned.

Day

H. Returns a Date value for the specified year, month and day. It also
handles relative Date expressions.

Activity: Using date and time functions and operators


Objectives
Use some of the functions and operators previously listed to solve the described problem.
Create a new report from the Orders table in the Xtreme Sample Database.

Instructions
1. Add Order ID, Order Date and Ship Date to the Details section.
2. Create a formula named Time to Ship that displays the number of days it took to ship each
order.

Creating FormulasLearners Guide

31

For internal use by CSC only

For internal use by CSC only

1. Using the Crystal Reports Help system, match the description to the correct item.

3. Create a formula named Day of Month that displays only the day of the month when each
order was shipped.
Use the Ship Date field to verify your result.
4. Create a formula named To be Shipped By that displays a date 10 days later than the order
date.
5. Add Day of Month and To be Shipped By to the report details.
6. Save the report as Using date and time functions.rpt.
For internal use by CSC only

For internal use by CSC only

Your report should look similar to this:

Using arithmetic operators


Arithmetic operators are used to calculate number or currency values.
Examples of arithmetic operators are:
Add (x+y)
Divide (x/y)
Percentage (x%y)
Add (x+y)

Adds values x and y.


The following examples are applicable to both Basic syntax and Crystal syntax:
5 + 6

Returns 11.
{file.QTY1} + {file.QTY2}

Returns 1487 where {file.QTY1} = 366 and {file.QTY2} = 1121.

32

Business Reporting SolutionsLearners Guide

Divide (x/y)

Divides value x by value y.


The following examples are applicable to both Basic syntax and Crystal syntax:
25/5

Returns 5.

Returns .333333.
Percentage (x%y)

Calculates value x as a percentage of value y. That is (x/y) * 100.


The following examples are applicable to Crystal syntax:
{file.BALANCE OUTSTANDING} % {file.CREDIT LIMIT}

Returns 30.00, where {file.BALANCE OUTSTANDING} = $1500 and {file.CREDIT LIMIT} = $5000.
{file.AMOUNT} % {file.CREDIT LIMIT}

Returns 32.26, where {file.AMOUNT} = 2257.87 and {file.CREDIT LIMIT} = 7000.


Note: If the denominator equals zero, the report is halted with a divide-by-zero protection. If
you want to avoid this type of problem, you should put a test in.
If {file.FORECAST} = 0 Then
0
Else
{file.SALES} % {file.FORECAST}

Using Boolean operators


Boolean operators are used to create conditions that require a logical relationship between two
or more values. Conditions that use Boolean operators are called Boolean expressions.
Four Boolean operators are:
And
Or
Not
<>
And

A And B means that both A and B must be true for the condition to be satisfied (to return a
TRUE value).
The following example is applicable to Crystal syntax using the And operator in Record Selection:

Creating FormulasLearners Guide

33

For internal use by CSC only

For internal use by CSC only

1/3

{Customer.Country} = USA AND {Customer.LastYearsSales} > 30 000.00

This is an example of using the And operator in a Formula:


If {Orders.Shipped} = True AND {Orders.Payment Received} = True
Then Closed Order Else
Pending Order

A Or B means that either A or B (or both) must be true for the condition to be satisfied (to return
a TRUE value).
Not

Reverses the True or False value of x.


The following examples are applicable to both Basic syntax and Crystal syntax:
not (A>B and B>C)

If A=5, B = 4, C = 3, the expression (A>B and B>C) is TRUE. Both conditions tied together by
the Boolean operator And are TRUE; thus, the entire statement has a value of TRUE. The Not
operator changes the value of the expression to FALSE.

Not Equal To : <>


The operator compares two values and returns TRUE if the values are not equal. The operator
returns FALSE if the values are equal.

Activity: Using Boolean operators


Objective
Use Boolean operators to figure out the salary ranges, dates and other criteria.

Instructions
1. Create a new report using the Employee table from the Xtreme Sample Database.
2. Display the employees first initial and last name (for example, J. Smith).
3. Insert the Hire Date and Current Salary. Remove the time portion from the Hire Date.
4. Format the headings to stand out.
5. Use Boolean formulas to indicate:
Anyone with a hire date year of 1991 and a salary greater than 75,000.
Anyone with a hire date year of 1993 or a salary less than 30,000.
All the employee first names that do not start with an X.
Note: These formulas should all return Yes/No results.

34

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Or

6. Save the report as Using Boolean operators.rpt.


Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

Creating FormulasLearners Guide

35

Defining control structures in Crystal syntax

After completing this unit, you will be able to:

Use basic if-then-else statements


Use multiple if-then-else statements
Use nested if-then-else statements
Use Select statements

Using basic if-then-else statements


Suppose you want to display a rating beside each customers orders figures in an orders report
depending on the level achieved: high orders or low orders. You can accomplish the task
using an If-Then-Else formula.
If {Orders.Orders Amount}>40000
Then
high orders"
Else
low orders"

Tip: The data type must be the same for the Then and Else parts of the formula (text, numeric,
date). For example, if the Then part of the formula prints a text string, the Else part of the formula
must also print a text string.

Activity: Using an if-then-else statement


Objective
Use an if-then-else statement to solve business problems.

Instructions
1. Open Using Boolean operators.rpt used in the previous activity.
2. Remove the Boolean formulas from the screen.
3. Use an If-Then-Else control structure to indicate only the 1991 hire year. Rename the formula
to Hire Year 1991.
4. Save the report as Using if then.rpt.

36

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Formulas without control structures execute each expression in the formula exactly once when
the formula is evaluated. The expressions are executed in a sequential fashion, from the first
expression in the formula to the last. Control structures enable you to vary this rigid sequence.
Depending upon which control structure you choose, you can skip over some of the expressions
or repeatedly evaluate some expressions depending on if certain conditions hold. Control
structures are the primary means of expressing business logic and typical report formulas make
extensive use of them.

Using multiple if-then-else statements


Use multiple if-then-else statements when there can be more than one true output for a formula.
This control structure allows you to test multiple conditions with each having their own output
when evaluated as True.
If {Customer.LastYearsSales} < 10 000 Then
Poor Sales
Else If {Customer.LastYearsSales} < 30 000 Then
Average Sales
Else Great Sales

Each statement is evaluated in order, until a True is returned. If all statements are false, the
final Else will be the output.

Activity: Using multiple if-then-else statements


Objective
Use multiple if-then-else statements to solve business problems.

Instructions
1. Open Using if then.rpt.

Creating FormulasLearners Guide

37

For internal use by CSC only

For internal use by CSC only

Your report should look similar to this:

2. Create a formula called Salary Category to display "Upper Range" for employees with a
salary above $75,000, "Mid Range" for employees with a salary between $50,000 and $75,000,
and "Low Range" for those with a salary below $50,000.
3. Add a Salary Category column to the report.
4. Save the report as Using multiple if then else.rpt.
Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

Using nested if-then-else statements


You can create powerful multi-condition formulas using the If-Then-Else operator.
Multicondition and nested If-Then-Else formulas use a general pattern.
A nested if-then-else follows this structure:
Field 1

Field 2

Result

If {file.FIELD1} = "A" Then


If {file.FIELD2} = "B" Then
"Action X"

38

Business Reporting SolutionsLearners Guide

Else
"Action Y"

Else

The If part of the expression can include text, numbers, Boolean expressions (Cust#<"10000"),
and formulas ({@Formula}), where @Formula is Boolean. The Then and the Else parts, however,
must both be of the same type (then text, else text; then number, else number). Mixing text and
number actions results in an error message.

Activity: Using nested if-then-else statements


Objective
Determine the raise for each employee based on their current salary and hire date.

Instructions
1. Open the report Using multiple if then.rpt.
2. Rename the Hire Year formula field to Raise. Rename the field heading Hire Year to Raise.
3. Use the following chart to modify the Raise formula so it will calculate the appropriate
raise.
Year Hired

1991

1992

1993

Creating FormulasLearners Guide

Salary Range

Raise

>75,000

10%

35,000 - 75,000

8%

<35,000

6%

>45,000

9%

<= 45,000

7%

>55,000

9%

39

For internal use by CSC only

For internal use by CSC only

"Action Z"

Year Hired

Raise

30,000 - 55,000

6%

< 30,000

4%

> 70,000

10%

<= 70,000

5%

4. Save the report as Using nested if then.rpt.


Your report should look similar to this:

Using Select statements


The select expression is similar to an If expression. The Select function can assist you in creating
formulas that are clearer and less repetitive than formulas using the If expression. Here is the
syntax for a select control structure:
Select select condition
Case select expression A:

Action for case A


Case select expression B:

40

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

1994

Salary Range

Action for case B


Default:

Default Action:

The default case is matched if none of the preceding cases match the select condition. Notice
that there is also a colon after the default. The default clause of the select expression is optional.
If the default clause is missing and no cases are matched, then the select expression returns the
default value for its expression type.
For example, to evaluate the {Customer.Fax} field to determine if the area code is for Washington
state (206, 360, 509), or British Columbia, Canada (604, 250), if the first three numbers of the
{Customer.Fax} are not found in the case statements then nothing is printed.
Select left({Customer.Fax},3)
Case 604, 250: BC
Case 206, 509, 360: WA
Default: ;

Activity: Using Select statements


Objective
Use a Select statement to solve business problems.

Instructions
1. Open the report Using nested if then.rpt used in the previous activity.
2. Modify the Raise formula by changing the multiple If-then-else statement into a SELECT
statement.
3. Save the report as Using select statements.rpt.

Creating FormulasLearners Guide

41

For internal use by CSC only

For internal use by CSC only

The expression immediately after the Select keyword is called the select condition. The
expression tries to find the first case that matches the select condition, and then executes the
action following the colon for that case. Notice that a select condition can be tested by one or
more select expressions in the same case.

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

42

Business Reporting SolutionsLearners Guide

Quiz: Creating formulas


1. What will Length(Business Objects) return?
2. {Employee.Employee ID} is a field from the Xtreme Sample Database. Will the following
concatenation work? Why? Why not?
My Employee no + {Employee.Employee ID}

For internal use by CSC only

For internal use by CSC only

3. What will the following return?


Business Objects[10 to 16]

4. What will the following return?


DateAdd(m,1,#11/08/2004#)

Creating FormulasLearners Guide

43

Lesson summary
After completing this lesson, you are now able to:
Use functions and operators
Define control structures available in Crystal syntax

For internal use by CSC only

For internal use by CSC only

44

Business Reporting SolutionsLearners Guide

Lesson 3

Managing Reports
Lesson introduction

For internal use by CSC only

For internal use by CSC only

Once your reports have been created with Crystal Reports you can manage your reports using
the Workbench and BusinessObjects Enterprise.
After completing this lesson, you will be able to:
Use the Workbench
Publish reports to BusinessObjects Enterprise

Managing ReportsLearners Guide

45

Using the Workbench


The Workbench is a tool designed to help you easily organize and access reports found in
different locations. In the Workbench, you can organize projects locally on your own machine,
or publish them to BusinessObjects Enterprise where others can share them.
After completing this unit, you will be able to:

Viewing the Workbench


In the Workbench, you can view reports, projects, and object packages that utilize reports from
multiple unrelated locations.

To view the Workbench


1. From the View menu, select the Workbench command.
The Workbench appears.
2. Click the title bar of the Workbench and drag the window to undock the Workbench.
3. Continue moving it until it redocks in another location.

46

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

View the Workbench


Organize Workbench contents locally

Note: You can also double-click an Explorer's title bar to change between docked and
free-floating mode. In free-floating mode, the Explorer can be dragged to any position.
When you drag the Explorer, a placement frame shows you where it will be placed. You
can also resize an Explorer by dragging any of its edges with the Resizing cursor.

Think of the items in folders in the Workbench as shortcuts or pointers that allow you to quickly
access a report in a distant location. In the Workbench, a project acts as a container used to
organize these shortcuts to existing reports stored in different locations. When a project is
published to BusinessObjects Enterprise as an object package, it can be accessed through
Enterprise by those with the correct permissions.

To create a project in the Workbench


1. Right-click in the white workspace area of the Workbench.
2. From the shortcut menu, select Add.
3. From the Add menu, select Add New Project.
A new project folder named Untitled Project appears.
4. Rename the project folder.

To add an existing report to a project


1. In the Workbench, right-click the project folder where you would like to add the existing
report.
2. From the shortcut menu, select Add.
3. From the Add menu, select Add Existing Report.
4. Select the desired report from the Open dialog box.
Note: You can also reorganize the files in a folder or folders by dragging and dropping
them where you want them to appear. You can also drag report files from Windows Explorer
and drop them into the folder of your choice in the Workbench.

Managing ReportsLearners Guide

47

For internal use by CSC only

For internal use by CSC only

Organizing Workbench contents locally

Publishing to BusinessObjects Enterprise


Publishing is the process of adding objects such as Crystal Reports to the BusinessObjects
Enterprise environment and making them available to authorized users.

For internal use by CSC only

After completing this unit, you will be able to:

Create a new object package


Add an existing object package to your Workbench
Use the publishing wizard to publish reports to BusinessObjects Enterprise
Distribute personalized content

Creating a new object package


An object package can be used to bundle reports together that can be transported and scheduled
as a singular entity. When published to the BusinessObjects Enterprise system, the package
can be accessed by other users.

To create and publish a new object package to BusinessObjects Enterprise


1. In the Workbench, right-click the project folder you would like to use as the basis for your
object package.
2. Select Publish to BusinessObjects Enterprise from the shortcut menu.
The Publish Object dialog box appears.
3. Select the appropriate location in the Enterprise.
4. Ensure that the Add as Object Package box is selected.
5. Click OK.

Adding an existing object package to the Workbench


After another user has published their object package to BusinessObjects Enterprise, users with
the appropriate permissions can add that object package to their own Workbench.

To add an existing object package to your Workbench from BusinessObjects


Enterprise
1. In the Workbench, right-click the target location for the object package.
2. From the shortcut menu, select Add.

48

Business Reporting SolutionsLearners Guide

For internal use by CSC only

When you publish a report to BusinessObjects Enterprise, an entry is made in the Central
Management Server (CMS) database. This database stores published reports which can be
viewed in the BusinessObjects Enterprise system. You can also publish a collection of reports
to the Enterprise system by creating an object package in the Workbench and then publishing
that object package to BusinessObjects Enterprise.

3. From the Add menu, select Add Object Package.


Note: If you are not currently logged in, you will be prompted to log onto BusinessObjects
Enterprise.
The Choose Object Package dialog box appears.
4. Select the source location for the object package.

Using the Publishing Wizard


As an alternative, you can use the Publishing Wizard to publish files or folders to
BusinessObjects Enterprise.

To publish reports to BusinessObjects Enterprise using the Publishing Wizard


1. Click Start Programs BusinessObjects XI 3.1 BusinessObjects Enterprise
Publishing Wizard.
2. On the first screen of the wizard, click Next.
3. Type your user name and password, and then click Next.
4. Do one of the following:
Click Add Folder. Select the folder whose contents should be published, and then click
OK.
Click Add Files. Use the Open dialog box to select the file that should be published and
then click Open.
5. Click Next.
6. Select the Enterprise location where you would like to publish your report(s). Click Next.
7. To verify the location of the report, click Show file names. Click Next.
8. In the category tree, select the categories where your report(s) should appear. Click the
Insert File button to add the file(s) to the category. Click Next.
9. Specify the update schedule by selecting an option for each file. Click Next.
10.Select the Use Object Repository check box to refresh report fields using the repository.
This only applies to reports that use Repository Objects. Click Next.
11.Check the Keep saved data when publishing report box to keep a reports saved data. Click
Next.
12.Select the option next to Publish without modifying properties. Click Next.
Note: Selecting Review or modify properties allows you to change the title, description,
format, and data source of the report.
The wizard displays a list of objects to be added to BusinessObjects Enterprise.

Managing ReportsLearners Guide

49

For internal use by CSC only

For internal use by CSC only

5. Click OK.

13.Click Next.
The wizard confirms the success or failure of each file.
14.Click Finish if you were successful. If you were unsuccessful, make the necessary changes
to the file(s), verify file locations, and click Retry which reruns the wizard.

Objective
Add reports you have created to the Workbench, and publish them as an object package to
BusinessObjects Enterprise.
The report in this activity must be saved without data. If saved with data BusinessObjects
Enterprise will not prompt you for the parameter.

Instructions
1. Open the Workbench.
2. Add a new project named Report Design II to the Workbench.
3. Add all the report files you saved during your progress through this course to the Report
Design II folder.
Once complete, your Workbench should look similar to this:

4. From the Workbench, select the project and publish to BusinessObjects Enterprise in theUser
Folders Administrator folder.

Distributing personalized content


Advanced report publishing, also known as report bursting, is a platform for the mass
distribution of personalized content. Multiple reports can be created based on different data
sources, combined into one desired file format (for example, PDF), loaded with personalized
content, and then sent to a dynamic list of recipientsall in one action. The content can be

50

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Activity: Publishing and viewing reports in BusinessObjects


Enterprise

Other than designing and exporting publication documents to BusinessObjects Enterprise,


report designers are responsible for preparing the following aspects of the publishing process:
Creating Dynamic Recipient Data Providers (DRDPs). DRDPs allow the publisher to
distribute publications to recipients who do not have BusinessObjects Enterprise user
accounts.
Adding Report Alerts to enable delivery rules. Delivery rules allow the publisher to specify
criteria for the conditional delivery of publications.

Creating Dynamic Recipient Data Providers (DRDPs)


If your company wants to distribute a publication to recipients who are not users of
BusinessObjects Enterprise, but whose information you have stored in an external data source
(such as a database, LDAP directory, or custom application), you can create a Dynamic Recipient
Data Provider (DRDP).
A DRDP allows the publisher to distribute a publication to recipients without BusinessObjects
Enterprise user accounts. It obtains the list of recipients and their profile values directly from
the external data source, thereby eliminating the need to create user accounts for the intended
recipients.
For Crystal Reports, a DRDP is a report, or a rowset, that lists data about recipients. The mapping
between the columns of data in the rowset and their meaning in the publication (for example,
recipient name, e-mail address, profile values) is managed by the publisher in BusinessObjects
Enterprise.
Tip: There are several different types of DRDPs. For instance, a DRDP can be based on Universe
queries defined in a BusinessObjects Web Intelligence or BusinessObjects Desktop Intelligence
report.
To provide an example, suppose that your company distributes a monthly regional brochure
to customers, but several of your new customers have not yet been entered in the BusinessObjects
Enterprise system. You create a report that returns information for the new customers from
your database. The report includes the following fields:

CustomerID
CustomerName
EmailAddress
Region

After you save this new report to BusinessObjects Enterprise, the publisher specifies it as the
DRDP for the brochure publication. The publisher maps the CustomerName and EmailAddress
fields from your new report to the user name and email address fields for the publication. The
publisher then personalizes the brochure based on the Region field.
When the report is published, the new customers receive the brochure that is appropriate for
their region.

Managing ReportsLearners Guide

51

For internal use by CSC only

For internal use by CSC only

archived, printed, or emailed in separate actions, or simultaneously. This feature makes


scheduling much faster and easier, and provides the ability to conduct cost effective one-on-one
marketing campaigns and other personalized high-volume reporting.

As a report designer, your role is to create a report that lists data about the intended recipients.
The publisher then uses this report to create a distribution list and personalize the publication.

DRDP Design considerations

A DRDP can return several different data types. If the publication is personalized, ensure that
the data type of a column is compatible with the corresponding field in the personalized report.
DRDPs support the following data types:

String
Number
DateTime
Boolean

Additionally, DRDPs must provide the following:


Column Headings
The publishing system requests this information from a DRDP to return a list of column
names for the field mapping operation.
Paging
A DRDP returns recipient records to the publishing system in batches. The page size of the
DRDP controls how many rows it returns to the publishing system at one time. At publishing
time, the publisher is able to preview and filter recipients from the data list, so you do not
need to filter for intended recipients at design time.
Note: The maximum number of rows that the publisher can preview at publishing time is
100, regardless of the batch size of the DRDP.

Multiple values for a single recipient


The publishing system supports a single recipient having multiple values for a profile (for
example, a manager managing multiple regions, or a statement containing information for
multiple accounts). In this case, a single recipient is associated with multiple rows in the rowset,
each containing the same value in the recipient ID column. This is illustrated in this table.
Recipient ID

Region

Role

RCPT123

California

Manager

RCPT123

Florida

Manager

All rows with the same recipient ID value are processed as one recipient. If you plan to distribute
a publication with multiple values for a recipient, it is best to sort the DRDP by recipient ID,
so that rowsets are grouped by recipient. Failure to follow this sorting guideline may result in
the generation of separate publication instances and the delivery of documents with partial
information.

52

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

When designing a DRDP, you must create a column to be mapped to recipient ID. You can
also include optional columns for email address and full name.

If multiple rows in the rowset have the same recipient ID but different full names or email
addresses, the publishing system treats this as a single recipient and results in one delivery.
For that recipient, the system uses the first full name and email address to appear in the report.

Live data and saved data

If the DRDP contains parameters, the default parameter value set in the Central Management
Console (CMC) will be used. The publisher is not able to change parameter values at publishing
time.

Sending to both BusinessObjects Enterprise users and dynamic recipients


You can distribute a single publication to both dynamic recipients and BusinessObjects Enterprise
users/groups at the same time. However, a publication can only have one DRDP.
If a dynamic recipient is also a BusinessObjects Enterprise user, even one with the same recipient
ID and email address, the system does not attempt to associate the dynamic recipient with the
BusinessObjects Enterprise user account.

Personalization with DRDPs


For personalized publications, you can create columns that contain the values used for
personalization. On a per document basis, for each document field that will be filtered on to
achieve personalization, the publisher can specify which column from the dynamic recipient
provides the data value for that field.
Each report can have zero to multiple fields to personalize on, and it is possible that multiple
report fields are personalized by the same column from the DRDP.
Note: The columns that contain user ID, email address, and full name may also be used for
personalization.

Personalizing with multiple columns


When a report is personalized with multiple columns, the combination of the values across the
columns is used, as illustrated in the example below.
Rowset:
Recipient ID

Region

Role

RCPT123

California

Manager

RCPT123

Florida

Team Lead

RCPT123

Florida

Manager

Column Mapping

Managing ReportsLearners Guide

53

For internal use by CSC only

For internal use by CSC only

In addition to choosing a report as the data source for recipient information, the publisher is
also able to specify whether data is refreshed from the database live, or whether saved data
from the latest instance is used.

Report field: Region <--> Region column


Report field: Role <--> Role column
This is the resulting filter to personalize the document for recipient RCPT123:
(State = 'California' and Role = 'Manager') or (State = 'Florida' and Role = 'Team Lead') or
(State = 'Florida' and Role ='Manager')

When a publication contains multiple reports, column mapping for personalization is specified
individually for each report. Across the reports, they may link to the same or different columns,
as illustrated in the example below.
Rowset:
Recipient ID

Region

Role

CostCenter

RCPT123

California

Manager

9876

RCPT123

Florida

Team Lead

9876

RCPT123

Florida

Manager

9876

Column Mapping
Report A: Report field: Dept <--> CostCenter column
Report B: Report field: Title <--> Role column
Report C: Report field: Region <--> Region column and Role <--> Role column
These are the resulting filters for each report:
Report A: Dept = 9876
Report B: Title = 'Manager' or Title = 'Team Lead'
Report C: (Region = 'California' and Role = 'Manager') or (Region = 'Florida' and Role
='Manager') or (Region = 'Florida' and Role = 'Team Lead')

To create a dynamic recipient list from a text file datastore


1. Create a text file that contains the recipients you want to send a specific report to and save
the file locally to My Documents.
Ensure that the recipients are listed in a comma-separated values format.
Note: You will base your dynamic recipient report on this simple datastore.
2. Create a new Crystal report.
3. In the Database Expert, click Create New Connection.
4. Double-click the Access/Excel (DAO) folder.
5. From the Database Type list, select Text.
6. Click the ellipsis button next to the Database Name field.

54

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Personalizing multiple reports

7. Locate the folder in which you saved the text file.


8. Click the text file, and then click Open.
9. Click Finish.
10.Click the text file's table of values.
11.Add the table of values, and then click Next.

13.Click Finish.
You have created a list of dynamic recipients that connects to a datastore.
14.Save the report to BusinessObjects Enterprise.
You can create a folder in which to save the report, or you can save the report to a
predetermined location on the Enterprise system. This report is the one that the publisher
uses to create a distribution list and personalize the publication.

Active Directory recipients


Windows users must create a special type of DRDP for Active Directory recipients.
Unix users can use the ODBC Driver for eDirectory to perform SQL calls to Novell eDirectory.
For more information about the ODBC Driver for eDirectory, see
http://developer.novell.com/wiki/index.php/ODBC_Driver_for_eDirectory.

To create a DRDP for Windows Active Directory Recipients


1. Create a new report with the Standard Report Creation Wizard.
2. In the Available Data Sources tree, expand the Create New Connection folder and
double-click the OLE DB (ADO) folder.
The OLE DB (ADO) dialog box appears.
3. From the Provider list, select OLE DB Provider for Microsoft Directory Services.
4. In the Data Source field, type the IP address of your data source.
Note: Contact your server administrator to obtain this information.
5. Select the Integrated Security check box, and click Finish.
In the Available Data Sources tree, Active Directory Service Interfaces appears in the OLE
DB (ADO) folder.
6. Under Active Directory Service Interfaces, double-click Add Command.
The Add Command To Report dialog box appears.
7. In the Add Command To Report dialog box, write an SQL query that obtains the desired
information about your intended recipients, and click OK.
The new command appears in the Selected Tables tree.
8. In the Standard Report Creation Wizard, click Finish.

Managing ReportsLearners Guide

55

For internal use by CSC only

For internal use by CSC only

12.Add the recipients.

The DRDP report displays the desired information about your intended recipients. After creating
this report, you need to run the Server Intelligence Agent under an account with access to your
corporate network.

If you use BusinessObjects Enterprise to publish reports, you can use Report Alerts to create
delivery rules. A delivery rule allows the publisher to specify criteria for the conditional delivery
of a publication. The publisher specifies these rules in the CMC or InfoView, but they are based
on Report Alerts added by the report designer during report creation.
Be aware of these considerations when you use delivery rules:
Because delivery rules are based on Report Alerts, the criteria for conditional delivery are
always evaluated in the context of the report content.
The same delivery condition is evaluated for each recipient on the recipient list.
For publications scheduled to be printed, the print-out is produced regardless of the delivery
rule result. This happens because printing occurs at the report processing phase, which is
before the evaluation of the delivery rule.
As report designer, your role is to create the Report Alert upon which a delivery rule is based.
At publishing time, the publisher uses the Report Alert to design the delivery rule in
BusinessObjects Enterprise.

Recipient delivery rules


In cases where each recipient receives a personalized publication, the publisher can create a
recipient delivery rule. Recipient delivery rules are processed after personalization so that
delivery to each recipient is conditionally based on relevant information.
The following is an example of when you would use a recipient delivery rule.
Your company distributes monthly account summaries to your customers. During the creation
of the summary report, you add a Report Alert to notify you whether there has been any account
activity during the month. At publishing time, the publisher personalizes the report and creates
a delivery rule that sends the report to the customer only if the Report Alert indicates that the
customer had account activity during the month.

Global delivery rules


Publications, especially ones with many recipients, are computing intensive to process. For
unpersonalized publications that depend on a single condition, the publisher can create a global
delivery rule. Global delivery rules are checked before the publication begins to process, thereby
eliminating unnecessary processing when the condition fails to distribute.
The following is an example of when you would use a global delivery rule.
Your company distributes a quarterly bonus statement to employees, but the bonus is only
given if the company meets its quarterly revenue targets. You add a Report Alert in your
revenue statement to notify you whether the quarterly revenue targets have been met. At
publishing time, the publisher creates a global delivery rule that sends the report to employees
only if the targets have been met.

56

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Creating Report Alerts for delivery rules

To create a Report Alert for a recipient or global delivery rule


1. Determine the publication documents to be distributed.
2. Determine the condition that distribution is based on.
3. In the report that contains the conditional data, create a Report Alert to evaluate the data.
Note:

For internal use by CSC only

The conditional data does not need to be from a report included in the publication. The
publisher can create a delivery rule based on any document stored in BusinessObjects
Enterprise.
At publishing time, depending on business requirements, the publisher either:
- Personalizes the publication and creates a recipient delivery rule based on your Report Alert.
or
- Creates a global delivery rule based on the Report Alert. The global rule is evaluated before
the publication is processed.

Indexing saved data


You can increase the performance of a Crystal report by indexing its saved data. When you
create a Saved Data Index on a particular field, Crystal Reports can more efficiently filter on
that field. In particular, you will achieve considerable performance gainsespecially in larger
reportsby indexing fields that are referred to by record selection formulas.
Note: The benefits of Saved Data Indexes are largely unnoticeable in reports whose record
selection returns fewer than 10,000 records.
Saved Data Indexes are especially useful when you schedule your Crystal reports for viewing
through BusinessObjects Enterprise. For example, you want to provide your users with
information about yearly sales for North America, so you create a report. You also want sales
representatives to see figures for their individual regions, but you don't want them to see figures
for other regions, so you create a selection formula to limit the report. After you schedule the
report in BusinessObjects Enterprise and sales representatives view its instances, they see only
figures for their own regions. If you had also created Saved Data Indexes, the representatives
would see their records without having to wait for all records to be loaded.
In other words, the Saved Data Indexes allow a subset of the report's data to be accessed by a
user. The indexes are invoked by applying a selection formula in BusinessObjects Enterprise
at view time (that is, the selection formula applies a filter to an indexed field). These selection
formulas can be applied by setting them in a report viewer, or by setting them through a report
processing extension.

Managing ReportsLearners Guide

57

For internal use by CSC only

If the conditional data is not in a currently existing report, you must create a report that
contains it.

How Report Indexing works

If you have indexed the saved data by one or more fields, however, Crystal Reports already
knows which records contain particular values. Consequently, when a user accesses a particular
subset of the saved data from the indexed field, Crystal Reports can locate and format the
appropriate records more efficiently.
Once you have created Saved Data Indexes, they work entirely in the background. Users don't
know that the saved data is indexed, and the grouping, sorting, or formatting of the report
doesn't change at all. The indexes merely allow Crystal Reports to locate particular records
quickly, without passing through the saved data in its entirety.

Considerations for using Saved Data Indexes


There are some things that you should consider before deciding to use Saved Data Indexes:
Indexes work best in scenarios where a report contains a large set of data, but only small
subsets of the data are viewed at one time.
Large, complex reports can overload the Crystal Reports report engine.
For example, creating a large report with a selection formula that returns 90% of the report's
data will probably take up more memory and disk space than a report file without indexes.
In such a case, report processing will be slower.
Indexes require disk space; this disk space can add up to more than the space required for
the data itself. You trade the speed of applying selection formulas for the size of your report
files.
The Crystal Page and RAS servers are limited in how much caching occurs for different
users when selection formulas are applied. Therefore, when a user views a report file with
a selection formula and the Page Server takes up a certain amount of RAM, adding more
users could cause the Page Server to use even more RAM.

Using the Saved Data Indexes dialog box


The Saved Data Indexes dialog box appears when you select the Report Bursting Indexes
command from the Report menu.
Use this dialog box to select the fields you want indexed within your report's saved data. You
can increase the performance of a Crystal report by indexing its saved data. Indexes you specify
are created when you refresh the report's data.

Available Fields
This list shows all of the report and data source fields available for indexing. Some fields are
better than others to choose for indexing.

58

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

With a non-indexed report, Crystal Reports has to look at every record in order to locate values
that meet specified criteria. For instance, when a user requests a particular subset of the saved
data, or when a user requests the report but only has rights to access certain records, Crystal
Reports filters the saved data by checking each record for the appropriate values.

Indexed for Bursting


This list shows the fields you have chosen to create indexes for.

Auto
Click this button to automatically add fields that are used in Record Selection formulas.

Use the > arrow between the two lists to add fields to the Indexed for Bursting list from the
Available Fields list. Use the < arrow to remove fields you've already added. The double arrow
removes all fields.

Browse Data
Click this button to browse the field data. Click the Close button to return to the Saved Data
Indexes dialog box.

To index saved data


1. Open your report in Crystal Reports.
2. On the Report menu, click Report Bursting Indexes.
3. In the Saved Data Indexes dialog box, select the fields that you want indexed within the
saved data.
4. Click OK to return to Crystal Reports.
5. If you want to create the index immediately, refresh and save the report.

To index saved data


1. Open your report in Crystal Reports.
2. On the Report menu, click Report Bursting Indexes.
3. In the Saved Data Indexes dialog box, select the fields that you want indexed within the
saved data.
4. Click OK to return to Crystal Reports.
5. If you want to create the index immediately, refresh and save the report.

Managing ReportsLearners Guide

59

For internal use by CSC only

For internal use by CSC only

Arrow buttons

Quiz: Managing reports


1. What are the components you might find in the Workbench?
2. What are the different ways you can publish Crystal Reports to BusinessObjects Enterprise?

For internal use by CSC only

For internal use by CSC only

60

Business Reporting SolutionsLearners Guide

Lesson summary
After completing this lesson, you are now able to:
Use the Workbench
Publish reports to BusinessObjects Enterprise

For internal use by CSC only

For internal use by CSC only

Managing ReportsLearners Guide

61

For internal use by CSC only

For internal use by CSC only

62

Business Reporting SolutionsLearners Guide

Lesson 4

Using Variables and Arrays


Lesson introduction

Note: The discussion in this lesson is specific to Crystal syntax and does not cover Basic syntax.
After completing this lesson, you will be able to:
Use variables
Use arrays

Using Variables and ArraysLearners Guide

63

For internal use by CSC only

For internal use by CSC only

Variables and arrays are both placeholders for values in a formula. A variable holds one value
at a time but an array can hold a number of values.

Using variables
The formula language becomes very powerful through the use of variables. Crystal Reports
enables you to use variables in formulas to streamline formulas and expand formula capabilities.

Define variables
Declare a variable
Assign a value to a variable
Reference a variable in a formula

Defining variables
A variable represents a specific data item, or value, and acts as a placeholder for that value.
When a formula encounters a variable, the formula searches for the value of the variable and
uses it in the formula. Unlike a constant value, which is fixed and unchanging, a variable can
be repeatedly assigned different values. You assign a value to a variable and the variable
maintains the value until you later assign a new value. Because of this flexibility, you must
declare variables before you use them so that Crystal Reports is aware of them and understands
how you intend to use them.
To use a variable in a formula, you must:
Declare the variable.
Assign the value of the variable.
Reference the variable.

Declaring a variable
Crystal Reports requires you to declare all variables prior to using them. When you declare a
variable, you tell the program:
1. Scope - where you would like the variable to be available.
2. Data Type - the type of data you want the variable to hold.
3. Name - the name you intend to use for the variable.
The program uses this information to set aside a piece of memory for receiving and storing the
values that are assigned to the variable.

Identifying the scope of the variable


When using variables in formulas you should identify the variable scope. The scope of a variable
describes where you would like the variable to be available. The three variable scopes in Crystal
Reports are:
Global

64

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

After completing this unit, you will be able to:

Global variables can be referenced and used in any formula within a single report. If no

scope is declared for the variable this is the default scope.


Shared
Shared variables can be referenced and used by any formula in a subreport or the main

report of a single report. The shared variable can be referenced and utilized more than once
and by more than one subreport.
Local
declared.
Tip: If you declare a Global variable with the same name and data type in two or more formulas,
the formulas share the same variable name and value. Thus, if one formula sets the value of
the variable, the variable in the second (and additional formulas) reflects the change. Local
variables are the most efficient of the three scopes since they occupy the least amount of space
in memory. In addition, they do not interfere with one another in different formulas. For these
reasons, it is best to declare variables to be local whenever possible.

Determining the data type of the variable


The data type of a variable determines the type of data that can be stored as a value in that
variable. You can create a variable with one of seven data types:
BooleanVar - Boolean
NumberVar - number
CurrencyVar - currency
DateVar - date
TimeVar - time
DateTimeVar - date/time
StringVar - string
The data types correspond to the data types used throughout Crystal Reports. The Variable
Declarations are available in the Operators box of the Formula Editor.

Naming the variable


Use these guidelines to name the variable:
The variable name must not exceed 254 characters.
The variable cannot have the same name as a Crystal Reports operator or built-in function.
The variable name cannot contain blank spaces.
The variable name cannot begin with a numeric character.

Separating commands
When you have multiple statements in a formula, you separate the statements using a semicolon
so that Crystal Reports knows where one statement ends and the next begins. It is important

Using Variables and ArraysLearners Guide

65

For internal use by CSC only

For internal use by CSC only

Local variables can only be referenced and utilized within the formula in which they are

to remember that without semicolons, Crystal Reports treats the entire formula as a single
statement, even if the commands are separated by a carriage return.
When declaring a variable, add a semicolon at the end of the declaration statement.
Some sample variable declaration statements are:

Assigning a value to a variable


Assign a value to a variable using an assignment statement. The assignment statement consists
of:
the variable name
The variable name is the name used to declare the variable.
the assignment operator
The assignment operator is a colon (:) followed by an equal sign (=).
the value you want assigned to the variable
The variable value can be any value that matches the data type of the variable.
a semicolon
The assignment statement must end with a semicolon.
You can assign a number to a number variable. You can also assign an expression that results
in a number or even a sequence of expressions. For a string variable you could assign a character,
a word, a sentence, or an expression that results in a string. A variable value can be a constant,
an expression, or a sequence of expressions.
For example, the assignment statement Amount := 100; breaks downs to:
Variable name
Amount

Assignment operator
:=

Value
100

Semi-colon
;

Combining a variable declaration and assignment expression


You can also declare a variable and assign it a value in a single line of formula code. To do this,
declare the variable, allow a blank space, enter the assignment operator, and then assign the
value. For example, to declare a currency variable SellPrice and assign the value of the Cost
field ({product.PRICE (SRP)}) times two, use this expression:
Local CurrencyVar SellPrice := {product.PRICE (SRP)} * 2;

66

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Global StringVar y;
Local NumberVar My_Number;
Shared BooleanVar bTest;

Referencing a variable
Referencing a local variable
To refer to a variable within a formula, use its name. For example, if you declare a number
variable called NumVar and you wish to add 100 to this variable value, write:
NumVar := NumVar + 100

To display the contents of the NumVar variable as the result of your formula, write:

Referencing global or shared variable


When referencing a variable between formulas the scope of the variable must be either global
or shared. Once you have the variable declared with the correct scope, referencing a variable
between formulas is the same as referencing a variable within one formula. In order to reference
a variable between formulas, declare it by type and name as you would within one formula.
For example, if a variable is declared as Global NumberVar nNumVar and is assigned a value of
100 in @Formula1 then use the same declaration statement, Global NumberVar nNumVar, to
display the value held by the variable in a second formula, @Formula2.

Making a formula more efficient using a variable


Variables shorten the amount of time required to write formulas. For example, you want to
evaluate the {customer.FAX} field to determine the customers location. Without the benefit
of variables, you need to write the formula similar to this:
If left({customer.FAX},3) = "604"
Then "BC"
Else If left({customer.FAX},3) = 206"
Then "WA"
Else If left({customer.FAX},3) = 808"
Then "HI"
Else Unknown

You must write out the instructions for extracting the area code from the telephone number
field (left({customer.FAX},3)) every time you want the formula to use the area code from
the current record.
By using a variable (for example, sCode), you write those instructions only one time.
StringVar sCode := left({customer.FAX}3)
If sCode = "604"
Then "BC"
Else if sCode = "206"
Then "WA"
Else if sCode = "808"
Then "HI"
Else "Unknown"

Using those instructions, the program automatically extracts the area code from the
{customer.FAX} field, and stores it in the variable each time it reads a new record. Reference
the variable sCode whenever you want to use the area code from the current record in your
formula.

Using Variables and ArraysLearners Guide

67

For internal use by CSC only

For internal use by CSC only

NumVar

Activity: Referencing variable values


Objective
Use a variable to hold a database value and use variable values in a report.

Instructions

2. Enhance the Raise formula by replacing Employee.Hire Date with a local variable to figure
out the year and test the variable for the proper year.
3. Add another local variable that replaces the salary amount.
4. Save the report as Using a variable.rpt.
Your report should look similar to this:

5. Add a formula that contains a variable to store a Cost of Living Increase amount of 2%.
6. Increase the employee salary amount by the cost of living increase amount, and then calculate
the raise.
7. Add a text box to the report header that states Cost of Living increase: x% (x being the cost
of living increase amount).
Note: Display the increase as a whole number without any decimal places.
8. Save the report as Referencing variable values between formulas.rpt.

68

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

1. Open Using select statements-1.rpt.

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

Using Variables and ArraysLearners Guide

69

Using arrays
Variables are used to hold one value whereas an array is used to hold multiple values.
After completing this unit, you will be able to:

Defining an array
When there are two or more data items, the collection of data items is given a single name
instead of giving each data item a separate variable name. This collection is called an array.
The individual data items contained in an array are known as the array elements. The elements
in the array are numbered by their position in the array, referred to as an index.
Note: Crystal Reports supports single dimensional arrays with a maximum size of 1000 elements
only.

There are two types of arrays; static and dynamic . In a static array the elements are set and
remain the same every time the report is run, regardless of the data included on the report. In
a dynamic array the elements of the array change based on the data included on the report.
In order to use an array within Crystal Reports, you must:
declare the array
assign a value to the array
reference elements of the array

Declaring an array
Crystal Reports requires you to declare all arrays prior to using them. Declaring an array is
similar to declaring a variable. It requires four elements: scope, data type, the keyword array,
and a name.
Scope Datatype Array Name;

For example,
Global StringVar Array MyArray;

Identifying the scope of the array


Arrays share the same scope declarations as variables; global, shared and local.

Determining the data type of the variable


Arrays share the same scope data types as variables:
BooleanVar - Boolean
NumberVar - number

70

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Define an array
Declare an array
Assign values to an array

CurrencyVar - currency
DateVar - date
TimeVar - time
DateTimeVar - date/time
StringVar - string

Assigning values to an array


Assign values to an array using an assignment statement. The assignment statement consists
of:
the array name
the assignment operator
the list of values you want assigned to the array, enclosed in square brackets [ ]
a semi colon
Name:= [element1, element2, element3];

For example,
MyArray := [car, bus, taxi];

Combining an array declaration and assignment expression


You can also declare an array and assign it values in a single line of code.
Scope Datatype Array Name := [element1, element2, element3];

For example, to declare an array to store various modes of transportation:


Global StringVar Array MyArray := [car, bus, taxi];

Referencing the elements of an array


To reference one element of an array within a formula, use the subscript operator.
Name[N]

For example, to reference the second value of the array declared in the various modes of
transportation example:
MyArray[2]

This array returns a value of bus.

Changing the element values of an array


To change the values of the elements within an array, you need to reference the element and
assign a new value to this element.
Name[N] := new_value;

For example, to change the value of the second element of the MyArray array:
MyArray[2] := airplane;

Using Variables and ArraysLearners Guide

71

For internal use by CSC only

For internal use by CSC only

The data types correspond to the data types used throughout Crystal Reports.

Tip: Remember to search Help for any functions on which you may need additional information.

Activity: Building and referencing an array


Objective
Create a collection of related elements and reference them using an array.

1. Create a new report using the Employee table from the Xtreme Sample Database.
Note: Do not include any fields on the report.
2. Create a formula called Class Names and declare an array variable to store the first names.
3. Assign the following values as elements of the array: Jim, Hans, Jacques, Hitomi.
4. Add your own name as the last element in the array.
5. Display your name in the report using the array.
6. Save the report as Building and referencing an array.rpt.
Your report should look similar to this:

72

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Instructions

Activity: Referencing an array between formulas


Objective
Reference an array variable from one formula in another.

Instructions

2. Make a second formula Display Class Names that references the variable from the Class
Names formula using the JOIN function.
3. Separate each element with a comma and a space , .
4. Save the report in the Workbench as Referencing an array between formulas.rpt.
Your report should look similar to this:

Using Variables and ArraysLearners Guide

73

For internal use by CSC only

For internal use by CSC only

1. Open Building and referencing an array.rpt.

Quiz: Using variables and arrays


1. What is the scope of this variable?
numberVar nAge;

2. Rewrite the variable declaration to make it work.

3. Rewrite the variable declaration to make it work. Assume the declaration is at the beginning
of a formula that has more than one statement.
currencyVar cSalary

4. Rewrite this array declaration to make it work, assuming that the statement is not at the
end of the formula.
global numberVar CustomerID := [345, 894, 938]

5. From the following array, how would you display dog?


local stringVar Array Farm := [sheep, goat, cow, dog, cat];

74

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

local string sName;

Lesson summary
After completing this lesson, you are now able to:
Use variables
Use arrays

For internal use by CSC only

For internal use by CSC only

Using Variables and ArraysLearners Guide

75

For internal use by CSC only

For internal use by CSC only

76

Business Reporting SolutionsLearners Guide

Lesson 5

Creating Report Templates


Lesson introduction

For internal use by CSC only

For internal use by CSC only

Report Templates are a quick and efficient means of applying standardized formatting to
multiple reports.
After completing this lesson, you will be able to:
Apply report templates
Build a template without a data source
Remove a template

Creating Report TemplatesLearners Guide

77

Applying report templates


A template is an existing report file whose formatting can be added to a new report. At the
same time, the formatting of the template reports fields and report objects are applied to the
new report. Use templates to give reports a consistent look without having to format each one
individually.

Apply a predefined template


Use an existing report as a template

Applying a predefined template


There are two ways to apply a template to a report; the Standard Report Creation Wizard or
the Template Expert.
There are a number of predefined templates installed with Crystal Reports. Examples of
predefined templates are:
Confidential Underlay
Gray Scale
High Contrast

To apply a template in the Standard Report Creation Wizard


1. From the File menu, select the New command.
2. From the New submenu, select Standard Report.
The Standard Report Creation Wizard appears.
3. The wizard prompts you to enter data with a unique screen for data, fields, grouping,
summaries, group sorting, chart, and record selection.
4. In the Template screen of the Standard Report Creation Wizard, choose a template from
the list of available templates.
By default, the sample templates shipped with Crystal Reports are installed at:
\Program Files\Business Objects\Crystal Reports 12\Templates

An example of the chosen report appears in the Preview area.


5. If you want to apply a template based on an existing report, click Browse.
6. In the Open dialog box, select a report (.rpt) file and click Open.
7. The report is added to the list of available templates.
8. If a template name and preview picture were saved (in the Document Properties dialog
box) with the report you selected as a template, then the information is on the Template
screen.
9. Click Finish.

78

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

After completing this unit, you will be able to:

Your report appears with its data formatted to match the template you selected.

To apply a template to an existing report


1. On the Report menu, click Template Expert.
The Template Expert appears.
Another way to do this is to click the Template Expert button on the Expert Tools toolbar.

Note: Any drill-down tabs, alerts, or analyzer views that are open will be closed before the
template is applied.

Activity: Using a predefined template


Objective
Apply Crystal Reports templates to an existing report.

Instructions
1. Open Basic report_1.rpt.
2. Apply the Gray Scale template to the report.
3. Save the report as Using a predefined template.rpt.
Your report should look similar to this:

Creating Report TemplatesLearners Guide

79

For internal use by CSC only

For internal use by CSC only

2. Choose a template and click OK.

Using an existing report as a template


From the Template Expert, you can choose from a number of predefined templates, or you can
click the Browse button to search for an existing report to use as a template.

To apply an existing report as a template

2. Click Browse and browse to the report to be used as a template.


3. Click Open.
4. Click OK.

To add an existing report to the template list


1. Click File and then Summary Info.
2. On the Summary tab, enter a report title in the Title text box.
3. Save the file in the template directory.

To create a preview picture


1. Click File and then Summary Info.
2. Check the Save Preview Picture check box.
3. Click OK.
4. Preview the report.
5. Save the report to the template directory.

Activity: Using an existing report as a template


Objective
Use another report as a template for the currently open report.

Instructions
1. From the Workbench, open Basic report_1.rpt.
2. Use the existing report named Template report.rpt to format Basic Report_1.
3. Save the report as Using an existing report as a template.rpt.

80

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

1. On the Report menu, click Template Expert.


The Template Expert appears.

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

Creating Report TemplatesLearners Guide

81

Building a template without a data source


Previously you used an existing report as a template but it is not necessary to have a data source
to build a template.
After completing this unit, you will be able to:
Create a template without being connected to a data source

For internal use by CSC only

Crystal Reports allows the flexibility of creating a template without having to be connected to
a data source.
Template Field Objects can create more flexible report templates. These report objects do not
refer to existing database fields. Put them in your template report and format them as required.
When applying the template to another report, Crystal Reports displays that reports data with
the formatting specified. Therefore, when designing a template, knowing which data might be
in the report isnt necessary. Use Template Field Objects to take care of all the possibilities.
Template Field Objects are applied only to result fields: database fields, parameter fields, SQL
expression fields, and formulas. Special Fields are not considered result fields.

To create a report template without a data source


1. From the File menu, select the New command.
2. From the New submenu, select Blank Report.
The Database Expert appears.
3. Click Finish or Cancel.
You are presented with a blank report and can now do formatting that will later be used as
a template.

To add a Template Field Object to a template report


1. On the Insert menu, click Template Field Object.
A placement frame is attached to your cursor.
2. Place the Template Field Object frame on your template report.
A Template Field Object can be placed in any report section.
3. Right-click the object and click Format Template Field from its shortcut menu.
Tip: You can select multiple Template Field Objects and apply your formatting choices to
all of the objects by using the Format Objects option.
A list of formatting options appears. You can choose any of the options. When you choose
an option, the appropriate tab of the Format Editor appears.
4. Specify the formatting for your Template Field Object as required.

82

Business Reporting SolutionsLearners Guide

For internal use by CSC only

Creating a template without a data source

For each Template Field Object, a special formula field is created. You can see this formula
field in the Formula Workshop under the Formula Fields node.

To add sample data to a Template Field Object formula


If you want to use sample data in your report to see how your formatting will look, you can
reference database fields in these formulas.

1. In the Field Explorer, expand the Formula Fields node, select a Template Field Object, and
click Edit.
Tip: In the Formula Fields node of the Field Explorer and the Formula Workshop, Template
Field Objects appear as <TemplateField>.
2. In the Formula Editor, replace the Space(10) section of the argument with a database field
of the type you want to see in your sample, save your change, and close the Formula
Workshop.
3. Refresh your reports data.

Activity: Building a template without a data source


Objective
Create your own report template.

Instructions
1. Create a new Crystal Report without using a data source.
2. Insert two new template objects into the Details section.
3. Group on the second template object and delete it from the Details section.
4. Format all the objects on the report page with aqua font and a gray background.
5. Rotate the Page Header text object 90 degrees and make it bold. Stretch the box to about an
inch in height.
6. Add a Business Objects Logo from the course resources and place it in the Page Footer.
7. Go to File Summary Info and give the report the title My Template.
8. Save the report in the template directory. Name the file Building a template without a
data source.rpt.

Creating Report TemplatesLearners Guide

83

For internal use by CSC only

For internal use by CSC only

Note: To add sample data to a Template Field Object formula, you must have a data source.

Your report in the Design area should look similar to this:

For internal use by CSC only

For internal use by CSC only

84

Business Reporting SolutionsLearners Guide

Removing a template
The results of template application may not be exactly as you want so removal of the template
may be necessary.
After completing this unit, you will be able to:
Remove an applied template

For internal use by CSC only

Perhaps, after applying a template, you do not like the changes made to your report. As long
as you have not exited Crystal Reports since you applied the template, you can remove it from
your report.

To remove an applied template


To remove a template, you must use this option, as the Undo command is not available from
the Edit menu.
1. On the Report menu, click Template Expert.
Tip: Another way to do this is to click the Template Expert button on the Expert Tools
toolbar.
2. Choose Undo the current template and click OK.
The chosen template's features are removed and your report reverts back to the formatting
it had when you first opened it.
Note: To remove a template, you must use this option. The Undo command is not available
from the Edit menu.

Activity: Removing an applied template


Objective
Remove an applied template.
Remove a template from a report that contains a template.

Instructions
1. Open the report named Basic report_1.rpt.
2. Apply the template My Template to the report.
My Template is based on the report Building a template without a data source.rpt.

3. Remove the current template.


Do not save any changes to Basic report_1.rpt.

Creating Report TemplatesLearners Guide

85

For internal use by CSC only

Removing an applied template

Quiz: Using report templates


1. What type of files are report templates?
2. If the report to which a template is applied has fewer sections than the template what
happens?
3. For templates to be displayed in the Template list, in which directory must they be stored?

5. What are the four types of fields that Template Field Objects can be applied to?

86

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

4. How do you create a preview picture for a template?

Lesson summary
After completing this lesson, you are now able to:
Apply report templates
Build a template without a data source
Remove a template

For internal use by CSC only

For internal use by CSC only

Creating Report TemplatesLearners Guide

87

For internal use by CSC only

For internal use by CSC only

88

Business Reporting SolutionsLearners Guide

Lesson 6

Building Parameterized Reports


Lesson introduction

For internal use by CSC only

For internal use by CSC only

Parameters allow you to collect input from the report user and run the report based on the
input.
After completing this lesson, you will be able to:

Define and create parameters


Build a report with multiple parameters
Use edit masks and descriptions
Create a date range parameter
Group using parameters

Building Parameterized ReportsLearners Guide

89

Defining and creating parameters


By understanding the uses and creation of a parameter you expand the reusability of your
report.

Describe the common uses of parameters


Create a parameter with a static prompt
Create a parameter with a dynamic prompt
Use a parameter in a record selection
Respond to a parameter
Populate prompt values from values in a database
Use the list of values
Display a single-value parameter on a report
Describe values and sorting

Common uses of parameters


Parameters prompt the user of a report to enter information. Think of a parameter as a question
that the user needs to answer before the report is generated. The information users enter, or
the way they respond, determines what appears in the report. For example, in a report used
by salespeople, there might be a parameter that asks the user to choose a region. The report
returns the results for the specific region, instead of returning the results for all of the regions.
By using parameter fields in formulas, selection formulas, and in the report itself, you can
create a single report that you can modify whenever your needs change.
A parameter field can be identified by French braces and a question mark before the parameter
name. For example {?parameter_name}.

Creating a parameter with a static prompt


A static prompt is one that always contains the same values. For example, if your parameter
prompts for a country value, you could create a static prompt because the country list represents
a set of values that does not change often.
Use the following steps to create a parameter with a static prompt that lets users see a list of
customers that they can select a specific country from.
This procedure is made up of two sets of steps. The first is creating the parameter, and the
second is using the Select Expert to incorporate the parameter into the record selection filter.

To create a parameter with a static prompt


1. On the View menu, click Field Explorer.
2. Right-click Parameter Fields and click New.

90

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

After completing this unit, you will be able to:

The Create New Parameter dialog box appears.


3. Enter a name for the parameter in the Name field (up to 255 alphanumeric characters).
4. Select the appropriate Type from the list.
When creating a parameter whose Type is either Date or DateTime you can change the date
format to suit your needs.

6. To move all the field values to the Values area, click Actions and select Append all database
values.
7. In the Value Options area, enter the desired prompting text in the Prompt Text field (up
to 255 alphanumeric characters).
This is the text that appears in the Enter prompt values dialog box when the report is
refreshed.

8. Click OK.
9. Place the parameter using a static prompt into your report.
If you don't want to see the parameter field you dropped in your report, place it in a section
you can suppress, such as a report header or footer.

Creating a parameter with a dynamic prompt


A dynamic prompt is one that changes on a regular or irregular schedule. For example, if you
are prompting for customer name, you could create a dynamic prompt because the names in
your customer database probably change frequently. With a dynamic prompt, you can create
or specify a list of values that you can schedule for updates as often as you like through the
Business View Manager.

Building Parameterized ReportsLearners Guide

91

For internal use by CSC only

For internal use by CSC only

5. From the Value Field list, select the field of your choice.

For example, if you know that your sales force is rapidly expanding the regions that your
company sells to, you might schedule your region list of values to be updated every night.
Users who run a report that contains the region list of values will see the new values without
you having to manually update the list (as you would have to do with a static prompt).

To create a parameter with a dynamic prompt


With parameter fields, you can create a single report that can be customized quickly to meet a
variety of needs.
1. On the View menu, click Field Explorer.
The Field Explorer dialog box appears.
2. Select Parameter Fields, and then click New.
The Create New Parameter dialog box appears.
3. Type a name for the parameter in the Name field (up to 255 alphanumeric characters).
4. In the List of Values list, click Dynamic.
5. To use a new data source, select New in the Choose a Data Source area. To pick a list of
values from your repository, select Existing and choose an existing list of values from the
tree structure.
6. Click Insert, and then select the value of your choice from the Value list.
7. In the Options area, enter the desired prompting text in the Prompt Text field (up to 255
alphanumeric characters).
This is the text that appears in the Enter prompt values dialog box when the report is
refreshed.
8. Click OK.
9. Drag the parameter using the dynamic prompt to your report.
Note: If you do not want to see the parameter field you dropped in your report, place it in
a section you can suppress, such as a report header or footer.

Using a parameter in record selection


Once you have created a parameter field, you can use it (or reference it) in your report in place
of a fixed value.
Many of your reports may be similar to existing reports, but with modifications to the record
or group selection. Perhaps the report only needs to be modified to allow for a specific part

92

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

When you look at your dynamic prompt within Crystal Reports, it does not seem to be much
different from a static prompt. In the background, however, Crystal Reports stores the
information about the list of values that you created for this prompt. When you publish the
report to BusinessObjects Enterprise, the list of values becomes a separate entity that you can
schedule in the Business View Manager to ensure that the values are updated on a schedule
that you choose.

code, date range, or other value in the record selection. Create a parameter field and use it in
your record selection to allow for flexible reporting. When running the report you can type the
part code, date range, or other value you want for this occurrence of the report.
One of the most common uses of a parameter is in record selection (Select Expert).

To incorporate a parameter in record selection


With parameter fields, you can create a single report that can be customized quickly to meet a
variety of needs.
1. On the Report menu, click Select Expert.
Another way to do this is to click the Select Expert button on the Expert Tools toolbar.
2. Select Record.
The Choose Field dialog box appears.
3. Select the field you have created a parameter for and click OK.
The Select Expert appears.
4. Choose an operator from the drop-down list.
5. Choose the parameter from the adjacent drop-down list.

6. Click OK.
7. Click the Preview tab.
The Enter prompt values dialog box appears.
8. Select the value you want to base the report on.

Building Parameterized ReportsLearners Guide

93

For internal use by CSC only

For internal use by CSC only

For example, to easily modify a report for various regions, use a parameter field in place of a
specific region value {Customer.Country} = {?Country} where {?Country} is a parameter
field you have created. The value you select for the region parameter field is used for the record
selection in that occurrence of the report.

For internal use by CSC only

Responding to a parameter
You respond to a parameter in two different situations:
When you run the report for the first time.
When you refresh the reports data.
Note: If you select Prompt for new parameter values, the Enter Parameter Values dialog box opens
allowing you to enter the parameter values.

Other considerations include:


Enter String values exactly as they appear in the field or select them from the drop-down
list if it is available. If the parameter field enables multiple values, you can enter additional
parameter values using the Add button.
Enter Boolean values using this format: True or False.
Enter Number values exactly as they appear in the field.
Enter Currency values exactly as they appear in the field.
Enter Date values using this format: Date (Year, Month, Day). You can also access a calendar
to select the date by clicking the drop-down arrow beside the date.
Enter Time values using this format: Time (Hour, Minutes, Seconds). You can also select
the unit of time and then use the up and down arrows to scroll through the numbers.
Enter DateTime values using this format: Date (Year, Month, Day), Time (Hour, Minutes,
Seconds). You can also enter DateTime values by using the associated drop-down arrow to
access the calendar, and the up and down arrows to scroll through the time.

94

Business Reporting SolutionsLearners Guide

For internal use by CSC only

9. Click OK.
The report appears with the information for the prompt value you selected.

When running the report the first time you are prompted to enter a value for any parameter
fields used in your report. Each time you refresh data you are given the option of entering a
new parameter value or using the existing value.

To respond to a parameter for the first time


1. Click Preview to run the report for the first time.

For internal use by CSC only

For internal use by CSC only

The Enter Parameter Values dialog box opens.

2. Select the values for the parameter fields.


3. Click OK to generate the report using the parameter field values you defined.
If you specified a default value when you created the parameter field, the program uses
that value unless you specify a new one.
If you did not specify a default value, the program does not refresh the data until you supply
a new value.

Responding to a parameter when refreshing data


Each subsequent time you refresh data, you are given the option of entering a new parameter
value or using the existing value.

To respond to a parameter when refreshing data


1. Click Refresh to run the report.

Building Parameterized ReportsLearners Guide

95

2. Select the appropriate option for your application:


Select Use current parameter values to have the report refreshed with the current values.
Select Prompt for new parameter values if you want to run the report with different
values.
3. Click OK.
The report is refreshed.

Using the Parameter Panel


The Parameter Panel lets users interactively format and filter report data by changing parameter
values. It is located within the Preview Panel.
In the Create New Parameter and Edit Parameter dialog boxes, you can specify parameters to
display on the Parameter Panel via the Show on (Viewer) Panel option. You can choose one
of several settings:
Do not show
The parameter is not visible on the panel. Users must refresh the report to change the
parameter values.
Editable
Users can view and change the parameter values on the panel.
Read only
Users can view the parameter values on the panel, but cannot change them.
Note: Do not show is the default setting for a new parameter.
The Parameter Panel displays all parameters that have been set to Editable or Read only.
Depending on the type of parameter, users can add, delete, or modify parameter values either
by using the drop-down menus and applying their changes or by clicking the Advanced Dialog
button.
The following are some of the more commonly used types of parameters that must be modified
by clicking the Advanced Dialog button:

96

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

The Refresh Report Data dialog box opens.

Parameters with ranged values.


Dynamic parameters that use cascading prompts.

To create a parameter appearing on the Parameter Panel


1. On the View menu, click Field Explorer.
Tip: Another way to do this is to click the Field Explorer button on the Standard Toolbar.
The Field Explorer dialog box appears.
2. Select Parameter Fields and click New.
The Create New Parameter dialog box appears.
3. Enter a name for the parameter in the Name field (up to 255 alphanumeric characters).
4. Select the appropriate Type from the list.
Note: When creating a parameter whose Type is either Date or DateTime, you can change
the date format to suit your needs.
5. From the Value Field list, select a value.
6. Click Actions, and select Append all database values to move all of the applicable values
to the Values area.
This example will enable the user to choose from any of the values. If you want to limit the
selection, manually enter only the values that you would like the user to choose from.
7. Select Editable from the Show on (Viewer) Panel list.
This example will enable the user to edit the parameter value on the Parameter Panel. If
you want to show the parameter on the panel, but do not want to allow the user to edit it,
select Read only for this option.
8. Click OK.
9. Return to the Field Explorer dialog box, and drag the parameter onto your report.
The Enter prompt values dialog box appears.
Note: If you don't want to see the parameter field you dropped in your report, place it in
a section you can suppress, such as a report header or footer.
Tip: You don't need to drag the parameter onto the report if you plan on referencing it in
a conditional formatting formula or a selection formula. If you have set the parameter options
to Editable or Read only on the Parameter Panel, using the parameter in a formula will
automatically activate it on the panel.

Building Parameterized ReportsLearners Guide

97

For internal use by CSC only

For internal use by CSC only

On the panel, data parameters are differentiated from non-data parameters with a database
icon. When a user modifies the value of a data parameter, the report refreshes and accesses the
database to make the corresponding changes. When a user modifies the value of a non-data
parameter, the report is formatted or filtered based on saved data within the report. It does not
access the database.

Creating a saved-data record filter using parameter fields


You can design your report so that users can filter fields and records without refreshing
information from the database. Saved-data record filters combine the use of saved-data selection
formulas and the Parameter Panel.

It allows users to filter and re-filter report data without leaving the canvas of the report.
It eliminates processing demand on the database.
It reduces the time users spend waiting for data to be filtered.
It allows users to filter records in the report even if they do not have a connection or rights
to access the database at the time of viewing.

When planning to include a saved-data record filter in your report, it is important to consider
the following points:
To prevent report refreshing to the database, only non-data parameters should be added to
the Parameter Panel.
Exported reports retain all recently applied parameter changes.
Subreport parameters cannot be shown on the Parameter Panel.

To incorporate a parameter into a saved-data selection formula


1. On the Report menu, point to Select Expert and then click Saved Data.
The Choose Field dialog box appears.
2. Highlight the field on which you want to base record selection and click OK.
The Select Expert appears.
3. Use the drop-down lists to enter your selection criteria for the indicated field.
4. Choose the parameter from the adjacent drop-down list and click OK.
If the parameter is being referenced for the first time, the Enter Values dialog box appears.
5. Select your initial values and click OK.

Using optional parameters


Crystal Reports supports optional parameters. An optional parameter is a prompted value that
does not have to be supplied by the user.
Report designers should provide some guidance to the end user that a parameter is optional
by adding this information to the prompt text.
Optional parameters are treated by Crystal Reports as optional anywhere within the report
that they are used. You cannot set one instance of the parameter to optional and another to
mandatory.
Note:

98

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

This feature is particularly useful for several reasons:

After you set a parameter to optional, if you use the Select Expert, the system automatically
adds the selection formula for you using the HasValue() function.
The Formula Workshop Editor does not automatically add the formula. Only the Select
Expert automatically adds the formula for you.
If you change the parameter from optional to mandatory, the HasValue() function is not
automatically removed from your formula.

When the report engine evaluates any formula which references an optional parameter that
does not have a value, it generates a runtime error. All formulas that reference an optional
parameter should first use the HasValue() function to check if that parameter has a value before
evaluating it. This includes record selection formulas and saved data formulas.
Note: The system will not automatically drop a statement from the SQL WHERE clause. It is
the report designers responsibility to decide which statement to leave out based on HasValue()
testing.
Tip: Although you do not use the function in an activity, a sample formula using the HasValue()
function is available in the course resources. See Activity Resources\Lesson 6\Hasvalue
Syntax.txt.

To create an optional parameter


1. In the Value Options area of the Edit Parameter dialog box, set the Optional Prompt value
to True.

Populating prompt values from a database


Dynamic and cascading prompts allow you to populate prompt values from values in a database.
Prompts can be arranged in a cascade, where one value in the prompt constrains values in
subsequent drop-down lists. A single prompt definition can be stored in the Repository and
shared among multiple reports, improving both runtime scalability and design-time
productivity.
A dynamic prompt can include a cascading list of values, which adds additional levels of
selection for your users. For example, if you are prompting for a city value, but you also need
to know which country and region that city comes from, you could create a dynamic and
cascading prompt. In this case, first prompt for a country, and when that value has been selected,
the program prompts for a region by showing only the regions that apply to the selected country.
Finally, when a region value has been selected, the program prompts for a city by showing
only the cities that apply to the selected region. In this way, you can be sure that your user
picks the correct city (for instance, Vancouver, Washington, USA rather than Vancouver, British
Columbia, Canada).
As with a dynamic prompt that has only one value, you are able to create or specify a cascading
list of values that you can schedule for updates as often as you like through the Business View
Manager.

Building Parameterized ReportsLearners Guide

99

For internal use by CSC only

For internal use by CSC only

Handling a parameter with no value

To create a parameter with a cascading list of values


1. Open the sample report Group.rpt.
2. On the View menu, click Field Explorer.
The Field Explorer dialog box appears.
3. Select Parameter Fields, and then click New.
The Create New Parameter dialog box appears.

This example uses Supplier City.


5. In the List of Values list, click Dynamic.
6. Type prompting text for your prompt group in the Prompt Group Text field.
This example uses Choose the City in which your supplier is located.
Note: Prompt groups let you use a cascading list of values for other cascading prompts.
For example, if you set up such a list of values for an address prompt, you might want to
use the list for both shipping and billing addresses. In this case, you could create two prompt
groups for the same list of values; you might call one prompt group Shipping Address and
the other Billing Address.
7. Ensure that New is selected in Choose a Data Source.
Note: If your report already contains a list of values, or if you want to pick a list of values
from your repository, you can select Existing and choose an existing list of values from the
tree structure.
8. Click Insert.
The program automatically expands the Value list. Use this area to define the fields that
make up your cascading list of values. This example uses a cascade of Country, Region, and
City.
9. From the Value list, select Country.
10.Click the blank field under Country and select Region.
11.Click the blank field under Region and select City.
12.In the City value row, click in the Parameters column.
The parameters field should change to Supplier City - City. In this step, you are choosing
the field in your cascading hierarchy that should be bound with the parameter field that
you are creating. Because this particular parameter is intended to provide Crystal Reports
with a city value, you apply the parameter to City.
In the Prompt Text field (in the Value Options - Level 3 area), you may want to type
additional prompting text for each of the fields in your cascading list of values.

100

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

4. Type a name for the parameter in the Name field (up to 255 alphanumeric characters).

13.Click OK.
14.Return to the Field Explorer dialog box, and drag the Supplier City parameter into your
report.
15.If you dont want to see the parameter field you dropped in your report, place it in a section
you can suppress, such as a report header or footer.

Using a list of values


Dynamic prompts use lists of values. You can create a list of values in either Crystal Reports
or in the Business View Manager. Crystal Reports refreshes the data in a list of values when
you open a report that contains a dynamic prompt. You can also refresh the data in a list of
values by scheduling it in the Business View Manager.

Sharing common lists of values within a report


You can use a single list-of-values object for many unrelated prompts within a single report.
For example, in a report that shows shipments from suppliers to customers, shipments can go
from a supplier in one city to a customer in another city. You would want your report to prompt
for both supplier city and customer city; both have the same set of values. Because there are
many hundreds of cities in the database, you can break up this long list of values into countries,
regions, and cities. In that way, your users can navigate through hundreds of values by selecting
from three shorter lists.

Building Parameterized ReportsLearners Guide

101

For internal use by CSC only

For internal use by CSC only

This prompting text appears in the Enter prompt values dialog box when the report is
refreshed.

Using separate value and description fields

Using command objects as list-of-values data sources


Crystal Reports supports command objects as data sources for unmanaged lists of values. To
use this feature, you first create a command object using the Database Expert to return the
values that you want in your list-of-values object.
The query you create should return at least one database field per level in the new list-of-values
object. For example, if you want to build a Country, Region, City list-of-values object, your
query should return at least three columns from your database: Country, Region, and City.
You need to return all three values in a single select statement. There is no need for an order
by clause, because the prompting engine sorts the values according to your specifications.
Note: It is not necessary to link your command object to your report fields. In general, command
objects that you use only to populate lists of values do not need to be linked to your report. However,
if you want to use a column from this command object in your report, you need to link the command
object to the report.

All the command objects defined in your report appear in the value fields drop-down list, and
in the description fields drop-down list in the Create New Parameter dialog box. You can then
associate your list of values with the command object.

Null handling
Null values in the data returned by the list of values are displayed as null in the drop-down
list for that prompt. Your users can select these values, and any parameters associated with
that prompt receive the null value. You can test for this functionality in the Crystal Reports
formula language with the IsNull function.

To share a common list of values within a report


1. Create a report that contains fields for Country, Region, and City.
2. In the Field Explorer, select Parameter Fields and click New.
The Create New Parameter dialog box appears.
3. Type a name for the parameter in the Name field.
This example uses SupplierCity.

102

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

It is common in relational databases to make use of code fields that represent values. These
codes are often numeric or text strings that cannot be read by your users. For such cases, you
can create separate value and description fields in your list-of-values definition. You set the
value field to the parameter, and the description field appears in the prompting dialog box.
How the description field appears in the prompting dialog box is controlled by the prompt
option Prompt with Description Only. When set to True, only the descriptions are visible.
When set to False, both the values and descriptions are visible.

4. In the List of Values area, click Dynamic.


5. Type prompting text for your prompt group in the Prompt Group Text field.
This example uses Choose the City that your supplier is located in.
6. Click Insert, and from the Value list, select Country.
7. Click the blank field under Country and select Region, and then click the blank field under
Region and select City.

9. Click OK.
10.Return to the Field Explorer dialog box, select Parameter Fields, and click New.
11.Type a name for the second parameter in the Name field.
This example uses CustomerCity.
12.In the List of Values area, click Dynamic.
13.Type prompting text for your new prompt group in the Prompt Group Text field.
This example uses Choose the City that your customer is located in.
14.Select Existing, and click Country > Region > City.
15.Click OK.
You have created two prompts: a Country, Region, City hierarchy for the {?SupplierCity}
parameter, and a second Country, Region, City hierarchy for the {?CustomerCity} parameter.
By reusing the list-of-values object, you saved time and improved performance time in Crystal
Reports.
Note: You can also use an existing list of values if you have another parameter field that should
have a country value. For example, if you add a {?DivisionCountry} parameter to indicate the
corporate division that you want to report on, you could use the same list-of-values object in your
report. You would bind this parameter to the top-level value in your hierarchythat is, the Country
level of the Country, Region, City hierarchy.

To set separate value and description fields


1. Open the sample report named Group.rpt.
2. In the Field Explorer, select Parameter Fields and then click New.
The Create New Parameter dialog box appears.
3. Type a name for the parameter in the Name field.
This example uses Customer Name.
4. In the List of Values list, click Dynamic.
5. Click New and, in the Value area, select Customer ID.
6. In the Description field, select Customer Name.

Building Parameterized ReportsLearners Guide

103

For internal use by CSC only

For internal use by CSC only

8. In the Parameter Binding area, ensure that only the City value is bound.

7. In the Value Options area, set the Prompt with Description Only option to True.
8. Click OK.
9. When users see this prompt in the prompting dialog box, they do not see values from the
Customer ID field (the field on which the parameter is based), but rather, they see a list of
customer names.

If you are using parameter fields in a record selection or formula you may want to reflect this
value somewhere on the report. For example, if you are using the parameter field in record
selection, the report might be used once to display records from PA and another time for CA.
In such a case, the report is easier to understand if the record selection is displayed in the title
of the report.
If you create a text object to display text and the value for the parameter field, you can easily
create a dynamic report title.

Each time you preview the report, the title is displayed with the current parameter fields value.

If you used the parameter field in a formula, you may want to display the value somewhere
in your report, perhaps in a footnote. For example, if you used a parameter field in a formula
for the discount percentage, you could create a text object that displays the discount percentage
used in the report.

To display a single-value parameter on a report


1. Create a text object with a space in which to insert the parameter.
Note: This step is only necessary when combining the parameter value with other text, such
as in a report title.
2. Create a parameter to prompt for the value you want to display.
3. Insert the parameter field in place of text.
Each time you run the report, the value you select for the parameter field is reflected in the
text object.

104

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Displaying a single-value parameter on a report

Describing values and sorting


Default values
When refreshing report data, the Enter Parameter Values dialog box displays the last parameter
values chosen. Click this button to reset the parameter values to the default values.

The Show Current Parameter Values command lets you see all parameter values in the current
report.
This command is located in the Report menu and, when chosen, the Current Parameter Values
dialog box appears.
This dialog box is a read-only version of the Enter Parameter Values dialog box.
Use the Current Parameter Values dialog box to see all the parameter values in your current
report. If no parameters have values, the Parameter Fields list displays the message: <No
parameters have any values>.

Using parameters to control sort order


Group sort order and top or bottom N reports can have their sort values driven by a formula.
This feature means that you can use parameters to control sort order and the N value of a top
or bottom N report. The result is a single report that is flexible and scalable, reducing the total
number of reports for you to create and support.

Activity: Building a dynamic cascading parameter with optional


prompts
Objective
Create a report containing optional prompt for Country, Region, and City.

Instructions
1. Open Optional Parameter-1.rpt.
2. Create a new dynamic and cascading parameter named Where are they ordering from.
3. Set the parameter type to String, and set Dynamic.
4. In the Prompt Group Text field type Drill down from Country to City.
5. Add the values Country, Region, and City which will all use the parameter named Where
are they ordering from.
Tip: Remember to click in the Parameters area to the right of each value.
6. Select the appropriate Value Option settings to allow the user to bypass entering a value
for this parameter and to allow discrete values.

Building Parameterized ReportsLearners Guide

105

For internal use by CSC only

For internal use by CSC only

Current values

7. Use this parameter in Record Selection to return records pertaining to a country, then
regions and cities.
8. Save your report as Building dynamic cascading parameters with optional prompts.rpt.
Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

106

Business Reporting SolutionsLearners Guide

Building a report with multiple parameters


Crystal Reports allows you the flexibility to add more than one parameter to one report.
After completing this unit, you will be able to:
Create parameters with a single value or range of values
Create a report with multiple prompting values
Apply conditional formatting using parameters
Delete a parameter from a report

Specifying single or ranges of values


You can create parameters that require users to enter a single (discrete) value, or a range of
values. If you then include these parameters in your report's record selection, you can help
users find specific information,. For example, in the case of a record-selection parameter that
uses a discrete value, a user might enter a single country name to see sales figures for only that
country. In the case of a record selection parameter that uses a range of values, a user might
enter a range of countries (for example, Canada and France) to see sales figures for all the
countries in the range (in this case, Chili, China, Denmark, and England).

To specify single or range values


1. Select the Allow discrete values option or the Allow range values option to specify whether
the parameter field will accept a range of values.
If you select Allow discrete values, the parameter field will accept single values (rather
than ranges of values).
If you select Allow range values, then when you are prompted for parameter values,
you can enter a start value and an end value. For example, if you enter the values 5 and
10, the range is 5-10, and a report that uses this parameter for record selection will display
all records with values between 5 and 10. This also works for string parameter fields.
With a start value of A and an end value of E, a report that uses this parameter for record
selection will display all records within an alphabetical range of A-E.
Note: If the Allow multiple values and the Allow discrete values options are selected, the
parameter field will accept multiple single values. In this case, you can enter more than one
value, but these values will be evaluated individually and will not be interpreted as a range.
If the Allow multiple values and Allow range values options are selected, the parameter
field will accept multiple ranges.
2. If applicable, select the Min Length and/or Max Length options to designate the length of
the field.
For a Currency or Number parameter field, options for entering the Min Value and Max
Value appear.
For a Date, DateTime, or Time parameter field, options for entering the Start and End
values appear.

Building Parameterized ReportsLearners Guide

107

For internal use by CSC only

For internal use by CSC only

Creating a report with multiple prompting values


One parameter field can also accept multiple values, either single or range values. For example,
if you enter the values 5 and 10, a report that uses this parameter for record selection displays
all records with values 5 and 10.

To create a parameter with multiple prompting values

2. Select Parameter Fields, and then click New.


3. Type a name for your parameter.
4. Select a value type from the Type list.
5. From the Value Field list, select the table and field that you want to use to obtain your
prompting values.
6. Add the values from the field you selected by clicking Actions and selecting Append all
database values.
You can also import values, or you can create your own in the Value area under the Options
button.
7. In the Value Options area, select the Allow multiple values option and set its value to True
to enable your users to enter more than one prompting value for this parameter.
Both discrete and range-type values are allowed individually or in combination.
8. Click OK.

Activity: Building a report with multiple parameters


Objective
Create a report that accepts multiple values for a single parameter.

Instructions
1. Open Optional Parameter-1.rpt.
2. Create a static Customer Names parameter that supports multiple values.
Use the names from the Customer Name field as a default pick list for the customers.
3. Create a static Orders Greater Than parameter that selects only records with an order greater
than $1,000, $5,000, $8,000, or a user-specified value.
4. Create a record selection formula that displays only the customers with orders over the
amount specified by the Orders Greater Than parameter.
5. Update the report header label by adding the text Orders Greater than followed by the
Orders Greater Than parameter value.

108

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

1. On the View menu, click Field Explorer.

6. Preview the report.


7. Save the report as Building a report with multiple parameters.rpt.

For internal use by CSC only

For internal use by CSC only

Your report should look similar to this:

Applying conditional formatting using parameter fields


Parameter fields can be used to create conditional formatting formulas. You can customize
these formulas whenever you refresh the report data. A conditional formatting formula could
be used for color-flagging data that meets certain conditions. For example:
Sales representatives who sell more than 10% over quota.
Customers who have not ordered in the last quarter.
Inventory items that have not had any movement in the last month.
If the conditions under which you flag these items never change, you do not need to use
parameter fields. You can use formulas (for text flags) or conditional formatting (for border
flags). However, to change the conditions from report to report, you need to use parameter
fields in formulas and conditional formatting formulas.

To apply conditional formatting using parameters


1. Create the parameter field of the data type you need for the formula.
2. Create the formula and use the parameter field in place of the fixed value you would normally
use.

Building Parameterized ReportsLearners Guide

109

3. In the Format Editor, click the Conditional formula button next to the Color property on
the Font tab, and format the field using a conditional formatting formula.

Activity: Displaying a multiple value parameter on a report


Objective

Instructions
1. Open Building a report with multiple parameters.rpt.
2. Create a formula to display the customer names from the parameter created in the previous
activity.
3. Place the formula in the report header under the text object and format it to be displayed
the same way.
4. Preview the report with different values.
5. Remove Order Amount from the Select Expert. Delete the Orders Greater Than title from
the report header.
6. Using the Orders Greater Than parameter, format the Order Amount field to be printed
in red if it is greater than the parameter value entered. Show this formatting condition at
the top of each page.
7. Save the report as Displaying a multiple values parameter on a report.rpt.
Tip: Remember to search the extensive online Help section on functions and formulas.

110

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Use a formula to display selected values on a report.

Deleting a parameter from a report


There are several methods for deleting parameters within a report. The type of parameter you
are deleting determines the method you can use.
You can delete a parameter:
Used in the Select Expert.
Not used in a formula.
Used in a formula.

To delete a parameter used in the Select Expert


1. On the Report menu, click Select Expert.
Tip: Another way to do this is to click the Select Expert button on the Expert Tools toolbar.
The Select Expert dialog box appears.
2. Select Record, Group, or Saved Data, depending on if the parameter you want to delete is
used in record selection, group selection, or saved data selection.
3. Click the tab whose selection criteria uses the parameter to be deleted.
4. Click Delete.
5. Click OK to close the Select Expert.

Building Parameterized ReportsLearners Guide

111

For internal use by CSC only

For internal use by CSC only

Your report should look similar to this:

6. On the View menu, click Field Explorer.


7. Expand the Parameter Fields folder and click the parameter you want to delete.
8. Click Delete.

To delete a parameter not used in a formula

2. Expand the Parameter Fields folder and click the parameter you want to delete.
3. Click Delete.
A Crystal Reports dialog box appears confirming deletion.
4. Click Yes.
This parameter is removed from the Parameter Fields folder and from your report.

To delete a parameter used in a formula


1. On the View menu, click Field Explorer.
The Field Explorer appears.
2. In the Formula Fields folder, select the formula that contains the parameter you want to
delete.
3. Click Edit and delete the parameter field from the formula.
Note: If the parameter is used in more than one formula, it must be deleted from each
formula.
4. Close the Formula Workshop.
5. Expand the Parameter Fields folder and click the parameter to be deleted.
6. Click Delete.

112

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

1. On the View menu, click Field Explorer.


The Field Explorer appears.

Using edit masks and descriptions


With the use of edit masks and descriptions you can give the user guidance about how to
respond effectively to each parameter.
After completing this unit, you will be able to:

Using an edit mask


If the user is not provided with a list of default values or if they are allowed to edit the parameter
value, creating an edit mask can give the user some guidance about what values are acceptable.
The edit mask can be any of a set of masking characters used to restrict the values you can enter
as parameter values. The edit mask also limits the values you can enter as default values.
You can enter any of these masking characters or any combination:
Masking
character

Description

Enables an alphanumeric character and requires the entry of a character in the parameter
value.

Enables an alphanumeric character and does not require the entry of a character in the
parameter value.

Enables a digit [0 to 9] and requires the entry of a character in the parameter value.

Enables a digit or a space and does not require the entry of a character in the parameter
value.

Enables a digit, space or plus/minus sign, and does not require the entry of a character
in the parameter value.

Enables a letter [A to Z] and requires the entry of a character in the parameter value.

Enables a letter and does not require the entry of a character in the parameter value.

&

Enables any character or space and requires the entry of a character in the parameter value.

Enables any character or space and does not require the entry of a character in the parameter
value.

.,:;-/
(separator
characters)

Enable you to provide the user a faster method of entering data.

Inserting separator characters into an edit mask is similar to hard coding the formatting for the
parameter field. When the field is placed on the report, the separator character appears in the

Building Parameterized ReportsLearners Guide

113

For internal use by CSC only

For internal use by CSC only

Use an edit mask


Use a description

field object frame. For example, LLLL/0000, which depicts an edit mask that requires four
letters followed by four numbers.
Description

<

Causes subsequent characters to be converted to lowercase.

>

Causes subsequent characters to be converted to uppercase.

Causes the subsequent character to be displayed as a literal.

For example, the edit mask \A would display a parameter value of A. If the edit mask is 00\A00,
then a valid parameter value would consist of two digits, the letter A, and then two additional
digits.
Password
If you set the edit mask to Password, you can create conditional formulas specifying that certain
sections of the report become visible only when certain user passwords are entered. When you
enter the password, the actual letters are replaced by asterisk (*).
Note: Edit mask functionality is only available if the parameter is of a string data type.

Using a description
As the report designer you have the option of displaying the value and the description to the
report viewer or the description only. The value is the exact Boolean, currency, number, string,
date, datetime or time that will be used in the record selection or formula or wherever the
parameter has been referenced in the report. The description can be additional information
about the value that is displayed to the report viewer or it can take the place of the value.
You can add a descriptive message attached to the value. For example, if you have states listed
in their abbreviated two-letter form, you could spell out the state name as the description to
further explain the shortened version as a hint to users not familiar with the USA.
The values and the description can be different data types. For example, a value may be the
number 86 but the description might be the string eighty-six.

Activity: Using an edit mask


Objective
Utilize the edit mask functionality of parameters

Instructions
1. Open Using an edit mask-1.rpt.
2. Create a parameter that shows only regions that contain two characters.
3. Allow the users to select multiple values.

114

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Character

4. Remove the record selection based on the customer name and replace it with record selection
based on the region parameter.
5. Reorder the parameters so the region parameter is the first parameter.
Tip: Right-click Parameter in the Field Explorer, and then click Set Parameter order from
the shortcut menu.
6. Update the title formula to show the regions selected.
For internal use by CSC only

For internal use by CSC only

7. Save the report as Using an edit mask.rpt.


Your report should look similar to this:

Building Parameterized ReportsLearners Guide

115

Creating date range parameters


Using a date or datetime as a data type for a parameter is common practice.
After completing this unit, you will be able to:

Date and DateTime parameters


Date and DateTime parameters are often used in record selection to limit the records on a report
to a specific time period. As with other parameters the data type used in the parameter must
match the data type used on the record selection.
Note: Because of the variety of ways that date/datetime data is stored in databases, special attention
needs to be paid when working with Date and DateTime data types.

Creating a date range parameter


To create a date range parameter follow the same steps as you would for other parameters.
These Value Options are applicable to Date and DateTime parameters:
If the length of the parameter values must fall within a certain range, select the True setting
for theAllow range values option.
When you select Allow range values, you have the option to use the Start and End pair of
options to specify a mandatory range.
When a user prompts for new parameter values:
For Date, Time, and DateTime fields, the dialog box provides a DateTime Picker to help
enter these ranges quickly. The DateTime Picker consists of, where applicable, a text box
with arrows for selecting a time, and a calendar for selecting a date, which appears when
the user clicks the arrow button to the right of the date entry text box. The user can also
enter the date in YMD, MDY, and DMY formats.
If the user specifies range limitations after selecting a default table and default field, the
Values to be added list will be modified so that only those values that are within the range
appear on the list.

To display date range values on a report


There are times when records need to be shown based on a range of values. For example, you
might want to enter a range of dates for those records that should be included on a report and
reflected in the reports title.
1. Create a formula to display range values.

116

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Define the difference between date and datetime parameters


Create a date range parameter
Display a date range on a report

For a range of dates, the formula is similar to this example:


"Orders for " & Minimum({?Date Range}) & " to " &
Maximum({?Date Range})

Activity: Creating and displaying a date range parameter


Objective

Instructions
1. Open Using an edit mask.rpt.
2. Create a parameter named Order Date Range to allow the user to enter in a start and end
date.
Tip: The dates in this report are stored as datetime fields, not date fields.
3. Add this parameter to a Record Selection from Order Date.
4. Modify the formula title to include the Date Range information.
5. Preview the report with different date ranges.
6. Save the report as Creating and displaying a date range parameter.rpt.
Your report should look similar to this:

Building Parameterized ReportsLearners Guide

117

For internal use by CSC only

For internal use by CSC only

Create a date range parameter and display it on a report.

Grouping using parameters


Parameters can be used to determine the output for dynamic grouping.
After completing this unit, you will be able to:
Create a report with dynamic grouping

To set up grouping using parameter fields, create a formula that includes a parameter field
and then group based on that formula.
Using the Product table in the Xtreme database as an example, if you wanted to group by size,
color, or product class, you would create a parameter, for example {?GroupField}, and use it
in a formula. The code for this type of formula would be an If-Then-Else statement:
If {?GroupField} = "S" Then
{Product.Size}
Else
If {?GroupField} = "C" Then
{Product.Color}
Else
{Product.Product Class}

In order to reference this formula on the report, you need to create groups based on the formula.
This formula appears in the list in the Insert Groups dialog box.
When responding to the parameter prompt, if you enter S the formula groups by the Size field.
If you enter C the formula groups by the Color field. If you enter anything else, or do not enter
anything at all, the formula sorts by the Product Class field.

To define grouping using parameters


1. In the Create Parameter Field dialog box, create your parameter.
2. In the Formula Editor, create a formula that defines the grouping.
3. In the Insert Groups dialog box, choose the formula from the list to use as the group.
When you run the report, the program prompts you for a group option, and the formula
returns a value based on your input. The group facility uses that value as your group field.

Activity: Defining grouping using a parameter


Objective
Create a report where the grouping is determined by user input.

Instructions
1. Open Creating and displaying a range parameter.rpt.
Notice the order information is grouped by customer name.

118

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Creating a report with dynamic grouping

2. Create a parameter named Grouping Options. The prompting text should be Group the
report by City or Customer Name. Make it a String type.
3. Set the default values as City and Customer Name.
4. Create a new formula field named Grouping. If the parameter value equals City then the
formula should result in Customer.City. If the parameter value equals Customer Name then
the formula should result in Customer.Customer Name.
5. Modify Group #2 to be based on this grouping formula.
For internal use by CSC only

For internal use by CSC only

6. Display a header that describes the report grouping.


7. Preview the report with different parameter values.
8. Save the report as Defining grouping using a parameter.rpt.
Your report should look similar to this:

Building Parameterized ReportsLearners Guide

119

Quiz: Building parameterized reports


1. What are two locations where parameter fields are commonly used?
2. What is the syntax notation that identifies a field as a parameter?
3. What is the purpose of a default-value list?
4. How do you display a single-value parameter on a report?
For internal use by CSC only

6. If the discrete values A and G are entered as parameter values used in record selection and
the operator used is the equal sign, what records will be returned?
7. What function(s) would you use to display date ranges on a report?

120

Business Reporting SolutionsLearners Guide

For internal use by CSC only

5. In an edit mask, what is the difference between using A and a?

Lesson summary
After completing this lesson, you are now able to:

Define and create parameters


Build a report with multiple parameters
Use edit masks and descriptions
Create a date range parameter
Group using parameters

For internal use by CSC only

For internal use by CSC only

Building Parameterized ReportsLearners Guide

121

For internal use by CSC only

For internal use by CSC only

122

Business Reporting SolutionsLearners Guide

Lesson 7

Summarizing Data with Crosstabs

A crosstab object is a grid that displays values that are grouped and summarized in two
directions. This lesson provides you with information about how you can use crosstab objects
in your report.
After you complete this lesson, you will be able to:
Build a basic crosstab
Format a crosstab

Summarizing Data with CrosstabsLearners Guide

123

For internal use by CSC only

For internal use by CSC only

Lesson introduction

Building a basic crosstab


Crosstabs are a concise way to display a large amount of data and can vary in complexity.
After completing this unit, you will be able to:

Defining crosstabs
A crosstab object is a grid that returns values based on the criteria you specify. Data is presented
in compact rows and columns. This format makes it easy to compare data and identify trends.
It is made up of three elements:
Rows
Columns
Summary fields

In this crosstab, the rows are comprised of product types and countries are the columns.
The sum value is the count of products by country.
The rows in a crosstab run horizontally (from side to side). In the example above, Gloves
is a row.
The columns in a crosstab run vertically (up and down). In the example above, USA is a
column.
The summary fields are found at the intersection of rows and columns. The value found at
each intersection represents a summary (sum or count) of those records that meet the row
and the column criteria. In the example above, the value at the intersection of Gloves and
USA is four, the number of gloves sold in the USA.
A crosstab also includes several totals:

124

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Define crosstabs
Create a crosstab

At the end of each row is a total for that row. In the example above, this total represents a
single product sold in all countries. At the end of the Gloves row is the value eight, the total
number of gloves sold in all countries.
Note: The total column can appear at the beginning of each row.

At the bottom of each column is a total for that column. In the example above, this total
represents all products sold in a single country. The value at the bottom of the USA column
is four, the total number of products (gloves, belts and shoes) sold in the USA.
Note: The total column can appear at the top of each column.

At the intersection of the Totals column (totals for the products) and the Totals row (totals for
the countries) is a grand total. In the example above, the value at the intersection of the Total
Column and Total Row is 12, the total number of all products sold in all countries.

Creating a crosstab
You can create a crosstab as:
An object in an existing report.
A new report.
Things to keep in mind when using crosstab objects:
You can have multiple rows, columns, and summarized fields.
You can use print-time formulas as your rows or columns.
You can use Running Total fields as your summarized field.
You can include a group sort (top or bottom N) on the rows in your crosstab.
Note: Group sorting cannot be applied to columns.
You can insert as many crosstab objects in a report as you need.
You can insert the crosstab into either the Report Header or Report Footer, or the Group
Header or Group Footer.
You can place crosstab objects in subreports. This is useful when you want to refer to the results
from another report.

Summarizing Data with CrosstabsLearners Guide

125

For internal use by CSC only

For internal use by CSC only

In this crosstab, note the last column and the last row contain grand totals.

Creating a crosstab object in an existing report

You can drag and drop fields into the Rows, Columns, or Summarized Fields areas or use the
arrows when the field is selected. A crosstab field can have multiple fields in each box.
All the database and formula fields currently available are listed within the Fields list of the
Cross-Tab dialog box. When you use a database field as a row or column heading, the program
creates one row or column in the crosstab for each unique value in that database field. Each
database or formula field used as a summary field is tabulated for each row and column
intersection in the crosstab object.
You can also create new formulas in the Cross-Tab dialog box to use in the report as well as
change the summary operation and use grouping options. If you use a formula field, the
program creates and labels one row or column for each unique result of the formula.

To create a crosstab in an existing report


1. Open the report and then click the Design tab.
2. From the Insert menu, select the Cross-Tab command.
3. Drag the crosstab to the Report Header, Report Footer, Group Header, or Group Footer
section.
The upper boundary of the crosstab object is used to determine into which section you want
to insert the crosstab.
Note:

126

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Use the Cross-Tab Expert dialog box to set up the structure that makes up the crosstab.

If you drop a crosstab object in the Details section, it is automatically placed in the Group
Header section of the report because the Details section does not accept crosstabs.
You cannot place the crosstab object into sections that give you a stop cursor on your screen.
If you drop the crosstab object before you place it into position, the program drops the object
in a section that accepts crosstabs. You can then click it and move it into the desired position.
4. From the Format menu, select the Cross-Tab Expert command.
The Cross-Tab Expert dialog box opens.
For internal use by CSC only

For internal use by CSC only

This dialog box is made up of three tabs: Cross-Tab, Style, and Customize Style.
5. Drag the field you want to use as row headings from the Report Fields list to the Rows area.
You can also click the field in the Report Fields list then click the > arrow to add the field.
This field becomes the horizontal information.
6. Drag the field you want to use as column headings to the Columns area.
You can also click the field in the Report Fields list then click the > arrow to add the field.
This field becomes the vertical information.
7. Drag the field to summarize to the Summarized Fields area.
This field must be a value that both the rows and columns have in common.
You can also click the field in the Report Fields list then click the > arrow to add the field.
8. Click Group Options to apply additional structure to the crosstab by adding groups, if
needed.
9. Click the Style tab.
10.Select a predefined style.

Summarizing Data with CrosstabsLearners Guide

127

If you prefer to create your own format for the crosstab, click the Customize Style tab, then
customize the style as desired.
11.Click OK to exit the Cross-Tab dialog box.
12.Refresh the report to view the results.

Creating a crosstab with the Wizard is similar to creating a crosstab object with the Cross-Tab
Expert.
1. On the File menu, click New , and then click Cross-Tab Report.
The Cross-Tab Report Creation Wizard appears.

2. On the Data screen, locate the data source you want to use.
3. Select the tables that contain the fields to include in the report.
Tip: Use the Ctrl+click combination to pick a non-continuous range of tables and the
Shift+click combination to pick a continuous list of tables.
4. Click Next.
The Link screen appears. Verify that the linking is correct.
5. Click Next.
The Cross-Tab screen appears.

128

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

To create a crosstab using the Cross-Tab Wizard

6. Add the appropriate fields to the crosstab rows, columns, and summary fields by clicking
the > next to each area.
Tip: You can also add fields to the different crosstab areas by selecting and dragging them
to the Columns, Rows, or Summary Fields areas.
7. Select the summary operation you want to perform on the summary field from the list
beneath the Summary Fields area.

For internal use by CSC only

For internal use by CSC only

8. Click Next.
The Chart screen appears.
9. Select the kind of chart you want to see in your report:
Bar Chart
Line Chart
Pie Chart
Note: If you do not want to add a chart, leave No Chart selected.
10.Change the default charting information to suit your report.

Summarizing Data with CrosstabsLearners Guide

129

For internal use by CSC only

11.Click Next.
The Record Selection screen appears.
Use this screen to apply selection conditions. This limits the results that are returned in your
report to only those records that you are interested in.
12.Select the field to apply the selection to.
13.Click the > arrow.
The field is added to the Filter Fields area and the filter types list appears below it.
14.From the filter types list choose a filter method.
15.In the filter values list that appears, select the value(s) you want to filter on, and then click
Add.
16.Click Next.
The Grid Style screen appears.
17.Select a style.

130

Business Reporting SolutionsLearners Guide

For internal use by CSC only

The text areas are automatically populated with the appropriate information.

For internal use by CSC only

For internal use by CSC only

18.Click Finish.
The Cross-Tab report appears in the Preview tab.

Summarizing Data with CrosstabsLearners Guide

131

If you do not want the crosstab to appear in the Report Header, click the Design tab, and
move the crosstab to the Report Footer, Group Header, or Group Footer.
Note: If you place the crosstab in the Report Footer, right-click in the Report Footer grey
area and then select Dont Suppress to remove the footer suppression.

With crosstab objects, you can interchange the rows and columns. Once you have created and
previewed your crosstab you may decide that you would prefer to display the column information
as rows or vice versa. Change this by choosing the Pivot option from the shortcut menu.

1. Select the crosstab object.


2. Right-click and select Pivot Cross-Tab from the shortcut menu.
Some formatting may be lost when you use this option so check if you want to pivot your
rows and columns before you apply any formatting to them.
Note: The Pivot Cross-Tab option moves all the row fields to columns and all the column
fields to rows. To move only one column or row, select the desired field, hold down the left
mouse button (primary button), and drag it to the new row or column position on the
crosstab.

Activity: Building a basic crosstab object


Objective
Build a basic crosstab and display it on a report. Your users have been using a Sales by
Region report (Crosstabs-1.rpt in the course resources) that summarizes customer sales
by city for each region. The users are also interested in analyzing sales by suppliers and the
various products they provide for each region.

Instructions
1. Open Crosstabs-1.rpt.
2. Place the crosstab in Group Footer 1.
3. Use:
{Supplier.Supplier Name} and {Product.Product Name} as the rows.
{Customer.City} as the column
Extended Price (formula) as the summarized field
4. Customize the style of the crosstab so that row totals display on the right and column totals
display at the bottom.
5. Have each region on a separate page.
6. Save the report as Building a basic crosstab object.rpt.

132

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

To pivot the crosstab object

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

Summarizing Data with CrosstabsLearners Guide

133

Formatting a crosstab
Basic crosstabs show summarized data in its simplest form. To make crosstabs easier to read
and more meaningful, formatting is used.

Format a crosstab
Create a customized crosstab style
Conditionally format a crosstab
Highlight exceptions in a crosstab
Add a chart to a crosstab report

Using the crosstab formatting options


Format your crosstabs for presentation quality and readability using these options:
Change the width, height, and alignment of the crosstab cells.
Format individual fields.
Format the background color of an entire row or column.
Customize row/column labels.
Suppress empty rows and columns.
Suppress row and column grand totals.
Suppress subtotals and labels.
Keep columns together.
Repeat row labels if a row continues to the next page.
Tip: You can also use the Highlighting Expert to apply conditional formatting to a crosstab.

To change the width, height, and alignment of the cells


1. In the Design tab, click a row or column heading within the crosstab to activate the sizing
handles.
2. Click and drag one of the sizing handles to expand the width or height of the crosstab cell.
3. Click an alignment option on the Formatting toolbar to change the alignment of the data in
the cell.
You can choose between left, right, center, and justified alignment.
4. Click the Preview tab to view the changes.
Note: Changing one row or column heading affects all of the rows or columns within the
crosstab.

134

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

After completing this unit, you will be able to:

To format individual fields


1. Right-click the field you want to format and select Format Field from the shortcut menu.
The Format Editor opens.
2. In the Format Editor, make font, background, borders, numbering, currency symbols, and
printing characteristics choices.

To format the background color of an entire row/column


Use background colors to emphasize rows or columns within your crosstab.

1. Right-click the blank top-left area of the crosstab and select Cross-Tab Expert from the
shortcut menu.
The Cross-Tab Expert opens.
2. Click the Customize Style tab.
3. Click the row (in the Rows area) or column (in the Columns area), and select a color from
the Background Color drop-down list.
4. Click OK to return to the crosstab.
The row/column formats as specified.
Note: You can also apply separate background colors to row and column totals.

To customize row/column labels


By default, row and column labels are derived from the data on which you base your crosstab. You
can, however, customize row and column labels.

1. Right-click the row or column whose label you want to customize and select Format Field
from the shortcut menu.
The Format Editor appears.
2. On the Common tab, click the conditional formatting button adjacent to Display String.
3. In the Format Formula Editor, create formula text that describes the custom names you
want to use as well as the conditions under which these names should be applied.
4. Click Check to identify any errors in the formula.
5. Fix any syntax errors the Formula Checker identifies.
6. When the formula has the correct syntax, click Close.
You return to the Format Editor dialog box.
7. Click OK to return to your crosstab.
Your customized row and column names appear when the conditions you set are matched.

Summarizing Data with CrosstabsLearners Guide

135

For internal use by CSC only

For internal use by CSC only

3. Click OK to return to the crosstab.


The field is formatted as specified.

To suppress empty rows and columns


1. Right-click the blank top-left area of the crosstab and select Cross-Tab Expert from the
shortcut menu.
The Cross-Tab Expert opens.
2. Click the Customize Style tab.

4. Click OK to return to the crosstab.


The fields are suppressed as specified.

To suppress row and column grand totals


1. Right-click the blank top-left area of the crosstab and select Cross-Tab Expert from the
shortcut menu.
The Cross-Tab Expert opens.
2. Click the Customize Style tab.
3. Select either the Suppress Row Grand Totals or Suppress Column Grand Totals check
boxes, and then click OK.

To suppress subtotals and labels


If you have two groups in your crosstab you can suppress the subtotal and label for one of the
groups. If you have more than two groups you can suppress the subtotal and label of all of the
groups except for the lowest-level group.
1. Right-click the blank top-left area of the crosstab and select Cross-Tab Expert from the
shortcut menu.
The Cross-Tab Expert opens.
2. Click the Customize Style tab.
3. Click the field whose subtotal you want to suppress.
The Suppress Subtotal check box becomes available when you select a group.
The Suppress Label check box becomes active only after you select the Suppress Subtotal
option.
4. In the Group Options area, select the Suppress Subtotal check box.
5. Click the Suppress Label check box to suppress the label associated with the subtotal, and
then click OK.

To keep columns together


1. Right-click the blank top-left area of the crosstab and select Cross-Tab Expert from the
shortcut menu.
The Cross-Tab Expert opens.

136

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

3. Select either the Suppress Empty Rows or Suppress Empty Columns check box.

2. Click the Customize Style tab.


3. Select the Keep Columns together option, and then click OK.
When you print the report, the columns will not split across pages.

When you create a crosstab that is wider or longer than the specified page size, the program
automatically spans the printing process across enough pages to accommodate the size of the
crosstab. In the Preview tab, a line appears at each page break. For ease in reading, column
headings are repeated on subsequent pages. Row headings can also be repeated.
1. Right-click the blank top-left area of the crosstab and select Cross-Tab Expert from the
shortcut menu.
The Cross-Tab Expert opens.
2. Click the Customize Style tab.
3. Select the Repeat Row Labels check box, and then click OK.

Creating a customized crosstab style


The Customize Style tab is used to format your crosstab grid with background color, gridlines,
and cell margins.

Columns
This list displays the columns you selected for your crosstab. Select the field for which you
want to customize the style.

Rows
This list displays the rows you selected for your crosstab. Select the field for which you want
to customize the style.

Summarized Fields
Use the options in this area to determine how multiple-summarized fields are to be displayed.

Vertical
Choose this option to display multiple-summarized fields in a vertical list:
Summary 1
Summary 2
Summary 3

Horizontal
Choose this option to display multiple-summarized fields in a horizontal list:

Summarizing Data with CrosstabsLearners Guide

137

For internal use by CSC only

For internal use by CSC only

To repeat row labels if a crosstab spans more than one page

Summary 1

Summary 2

Summary 3

Show Labels
Choose this option to display the names of multiple-summarized fields. Labels can be displayed
for both vertical and horizontal summaries. These labels can also be modified by editing them
as you would any text field.

Use this check box to suppress the subtotal for a selected field. You must first have a field
selected in either the rows list or the columns list.

Suppress Label
Use this check box to suppress the label of a suppressed subtotal field. This check box is inactive
if the Suppress Subtotal check box is not selected.

Alias for Formulas


Enter an alias name for the selected row or column field. Creating an alias shortens long field
names, which is useful later when you refer to a field in a conditional formatting formula. The
field's original name is shown in this box by default.

Background Color
Use this list to select a color for the selected row or column field.

Show Cell Margins


Select this check box to have the program automatically format the cells of the crosstab. When
this check box is not selected, any extra space (white space) within the cells of the crosstab is
eliminated and the contents of the cells are adjusted to utilize the least amount of space in your
report.

Indent Row Labels


Select this check box to indent row labels on your crosstab. Use the adjacent box to specify the
size of the indent you want to see.

Format Grid Lines


When you click this button, the Format Grid Lines dialog box appears. In this dialog box, you
can define whether the grid lines are shown or not, as well as the color, style, and width you'd
like the grid lines to have.

Repeat Row Labels


Select this check box to have the program repeat row labels on every page for crosstabs that
print across more than one page.

138

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Suppress Subtotal

Keep Columns Together


Select this check box to have the program keep columns together on every page for crosstabs
that print across more than one page.

Column Totals on Top


Select this check box if you want column totals to appear at the top of the crosstab rather than
at the bottom (the default position).
For internal use by CSC only

Select this check box if you want row totals to appear on the left of the crosstab rather than on
the right (the default position).

Suppress Empty Rows


Select this check box to have the program remove empty rows from the crosstab. When this
check box is selected, any rows whose fields do not contain any records will be hidden.

Suppress Empty Columns


Select this check box to have the program remove empty columns from the crosstab. When
this check box is selected, any columns whose fields do not contain any records will be hidden.

Suppress Row Grand Totals


Select this check box to have the program remove the grand total from rows in the crosstab.

Suppress Column Grand Totals


Select this check box to have the program remove the grand total from columns in the crosstab.

Activity: Formatting a crosstab


Objective
Use the style tab of the Cross-Tab Expert.

Instructions
1. Open Building a basic crosstab object.rpt.
2. Include {Orders Detail.Quantity} as a second summary field in the crosstab.
3. Add the following formats:
Your users have been using crosstabs and would like another summary. They would also
like to have some formatting and styles added to the crosstab.
No decimal places for the {Orders Detail.Quantity} second summary field.
Each summary field to be a different color.
Column and row headings to stand out.

Summarizing Data with CrosstabsLearners Guide

139

For internal use by CSC only

Row Totals on Left

Remove all grand totals.


Add appropriate labels for the crosstab row and column headings.
4. Save the report as Formatting a crosstab object.rpt.
Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

Conditionally formatting a crosstab


You can use CurrentFieldValue to do conditional formatting on a field element, field object
or crosstab summary or label. CurrentFieldValue can return any field type.
CurrentFieldValue returns the current value of the field that is about to be printed.

To conditionally format a crosstab field


1. In the crosstab right-click the field to be formatted and select Format Field.
2. Locate the property you would like to conditionally format, such as a font color. Click the
Formula button.
3. Enter a conditional formula.
For example, if CurrentFieldValue = 0 then crRed.

140

Business Reporting SolutionsLearners Guide

To conditionally format cells in a crosstab


1. Right-click a cell value in the crosstab and select Highlighting Expert from the shortcut
menu.
Tip: You can also start the expert by clicking the Highlighting button on the Expert Tools
toolbar, or by clicking Highlighting Expert on the Format menu.

2. In the Highlighting Expert, click New to create a new conditional formula with default
settings.
3. In the Item editor area, click the Value of list and select the field that you want to base your
condition on.
Note: The field chosen here is the field upon which your condition is based and does not
need to be the field that is being formatted. To create a condition based on the values of the
field that is being formatted, select this field from the list. To base your condition on a
different report field, select it from the list of available fields.
The Value of list displays only those fields that you have added to the report.
4. Select a comparison from the second list (for example, is equal to, is less than, or is not
equal to).
This comparative statement works as the operator in the conditional formula created by the
Highlighting Expert.
5. Complete the condition by entering the desired value in the box.
Note: If the field selected in the Value of list is not numeric, the text box turns into a list of
available values, from which you must select one.
6. In the Font style, Font color, Background, and Border lists, specify the formatting changes
that you want to apply to the selected field when your condition is met.
Repeat steps 3 and 4 if you want to apply multiple highlighting conditions to the selected
field.
Note: You can use the Highlighting Expert Remove button to delete highlighting formulas
from the list.
7. Use the Priority arrows to specify the order in which you want Crystal Reports to apply
your conditions, and then click OK to return to your report.

Adding a chart to a crosstab report


Crystal Reports allows you to include a chart based on summary values in your crosstab report.
For example, with a crosstab that shows the amount of a certain product sold in each region
of the United States, you may want to include a chart showing the percentage of total sales
provided by each region for that product.

Summarizing Data with CrosstabsLearners Guide

141

For internal use by CSC only

For internal use by CSC only

The Highlighting Expert opens and displays the current formatting settings for the selected
cell.

To add a chart to a crosstab report


1. Right-click the blank top-left area of the crosstab, and then select Insert Chart.
The chart defaults in the Data tab reflect the crosstab as the source.
2. Change the values as necessary, and then click OK to accept the changes and insert the
chart.

Objective
Create a crosstab report with highlighting and a chart that corresponds with the crosstab
information.

Instructions
The users want a graphical view of the crosstab and key performance numbers should be
indicated (KPI).
1. Open Formatting a crosstab object.rpt.
2. Highlight the Extended price:
Green background and a white font color that meet or exceed $5000
Red background and white font color that fall below $500
Lime background and white font color that exceed $20000
3. Insert a chart using the crosstab as the starting point:

Supplier name by city using extended price


Make the chart a 3D riser
Use the pyramid option
Adjust the viewing angle if necessary
Remove the title and subtitle
Chart to appear in the group footer

4. Add a note before the crosstab that describes the highlighting conditions.
5. Save the report as Highlighting exceptions and charting crosstab data.rpt.

142

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Activity: Highlighting and charting crosstab data

Adding Calculated Members


You can add rows or columns to your crosstab by inserting a Calculated Member. These rows
or columns can contain custom calculations (for example, the difference in sales between two
regions) or can be used entirely for formatting purposes (for example, inserting a blank row
every three lines to increase readability).
You have complete flexibility in designing your own calculation formulas and can choose
whether they appear only once or repeat regularly in the crosstab.
This feature is particularly useful in the creation of financial reports.

To add a Calculated Member to your crosstab


1. In your crosstab, right-click the row or column header you would like to use as the first
value of your Calculated Member.
2. On the shortcut menu, point to Calculated Member, and select the chosen value as your
first value.
3. In your crosstab, right-click the row or column header you would like to use as the second
value of your Calculated Member.
4. On this shortcut menu, point to Calculated Member, and select the desired calculation.
A row or column that displays the results of the selected calculation appears in your crosstab.

Summarizing Data with CrosstabsLearners Guide

143

For internal use by CSC only

For internal use by CSC only

Your report should look similar to this:

To add a blank row or column to your crosstab


1. In your crosstab, right-click the header immediately preceding the desired location of your
blank row or column.
2. On the shortcut menu, point to Calculated Member, and depending on whether you have
clicked a row or column, click either Insert Row or Insert Column.
A blank row or column appears in your crosstab.

For internal use by CSC only

1. Right-click the top-left corner of your crosstab.


2. On the shortcut menu, point to Advanced Calculations, and click Calculated Member.
3. In the Calculated Members box, use the arrows to change the processing order of the
Calculated Members.
4. Click OK to save your changes and return to the report.
The crosstab recalculates the values of the Calculated Members without a database refresh.

Activity: Adding Calculated Members to a crosstab


Objective
Add Calculated Members to an existing crosstab.
The finance department for Xtreme mountain bikes has a current set of financial reports that
they would like enhanced. One of the reports not only groups their data by Account type,
Account Heading, and Account Name, but also gives monthly Actual and Budget data as well
as a Variance of the two.
The finance department would like to enhance this report to display Actual, Budget and Variance
information for multiple months.

Instructions
1. Open Variance Cross Tab_1.rpt.
2. Add a Calculated Member row that displays the difference between Sales Revenue and
Sales Returns. Select Sales Returns as the first value in the Calculated Member, so that the
Calculated Member row appears in the correct location on the report.
3. Change the header of the Calculated MemberDifference row to Net Sales.
4. Modify the Net Sales calculation formula to add all Revenue items, except Sales Returns
which is subtracted. Use the following formula:
Tip: You can copy the formula syntax for this activity from the code.txt file located in the
course resources in the Activity_Resources lesson folder.
GridValueAt(GetRowPathIndexOf("Revenue", "Sales Revenue", "Bike Sales Competition"), CurrentColumnIndex, CurrentSummaryIndex)

144

Business Reporting SolutionsLearners Guide

For internal use by CSC only

To change the processing order of Calculated Members

+ GridValueAt(GetRowPathIndexOf("Revenue", "Sales Revenue", "Bike Sales Hybrid"), CurrentColumnIndex, CurrentSummaryIndex)


+ GridValueAt(GetRowPathIndexOf("Revenue", "Sales Revenue", "Bike Sales Kids"), CurrentColumnIndex, CurrentSummaryIndex)
+ GridValueAt(GetRowPathIndexOf("Revenue", "Sales Revenue", "Bike Sales Mountain"), CurrentColumnIndex, CurrentSummaryIndex)
+ GridValueAt(GetRowPathIndexOf("Revenue", "Sales Revenue", "Sales Gloves"),
CurrentColumnIndex, CurrentSummaryIndex)

For internal use by CSC only

+ GridValueAt(GetRowPathIndexOf("Revenue", "Sales Revenue", "Sales Locks"),


CurrentColumnIndex, CurrentSummaryIndex)
- GridValueAt(GetRowPathIndexOf("Revenue", "Sales Revenue", "Sales Returns"),
CurrentColumnIndex, CurrentSummaryIndex)
+ GridValueAt(GetRowPathIndexOf("Revenue", "Sales Revenue", "Sales Saddles"),
CurrentColumnIndex, CurrentSummaryIndex)

5. Add a Variance Calculated Member to return Budget minus Actuals.


Tip: Select the 1/1/2005 Budget as the first value in the Calculated Member and then select
the 1/1/2005 Actuals as the second value in the Calculated Member.
6. Modify the insertion formula of the new Calculated Member column so that it appears to
the right of each month's Budget figures. Use the following formula:
GetColumnGroupIndexOf(CurrentColumnIndex)=2 and
GridRowColumnValue("Command.Amount_type")="Budget"

7. Preview the report. The new Calculated Member column displays the correct results for
1/1/2005, but the results for 2/1/2005 are identical, indicating that the calculation is incorrect.
Modify the calculation formula to make the calculation relative to each month's Budget and
Actual values. Use the following formula:
GridValueAt(CurrentRowIndex, CurrentColumnIndex-1, Current SummaryIndex) GridValueAt(CurrentRowIndex, CurrentColumnIndex-2, CurrentSummaryIndex)

8. Change the header of the Difference column to Variance.


9. Save your report as Adding Calculated Members to a crosstab.rpt.

Summarizing Data with CrosstabsLearners Guide

145

For internal use by CSC only

+ GridValueAt(GetRowPathIndexOf("Revenue", "Sales Revenue", "Sales Helmets"),


CurrentColumnIndex, CurrentSummaryIndex)

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

146

Business Reporting SolutionsLearners Guide

Quiz: Summarizing data with crosstabs


1. What are the three elements that make up a crosstab?
2. Name two sections that will not accept a crosstab object.

4. What are the three available chart types when creating a crosstab report using the Standard
Report Wizard?
5. What does the Pivot Cross-Tab option do?
6. What Crystal formatting function would be used to conditionally format a field element,
field object, summary or label in a crosstab?
7. How would you suppress an empty column in a crosstab?

Summarizing Data with CrosstabsLearners Guide

147

For internal use by CSC only

For internal use by CSC only

3. What happens if you attempt to place a crosstab object into a section that does not allow
crosstab Objects?

Lesson summary
After completing this lesson, you are now able to:
Build a basic crosstab
Format a crosstab

For internal use by CSC only

For internal use by CSC only

148

Business Reporting SolutionsLearners Guide

Lesson 8

Using Report Sections


Lesson introduction
Additional formatting options can be applied to entire sections of the report.

For internal use by CSC only

For internal use by CSC only

After completing this lesson, you will be able to:


Use sections
Use group-related functions to format sections
Use section underlay
Use multiple-column reporting

Using Report SectionsLearners Guide

149

Using sections
With the ability to conditionally format and organize sections you are able to make reports
multi-layered.
The ability to apply formatting to sections on a conditional basis greatly increases the power
and flexibility of reporting. For instance, you can conditionally apply background colors to
sections.

Use the Section Expert options conditionally


Create new sections
Delete sections
Move sections
Merge sections
Create page breaks

Using the Section Expert options conditionally


The Section Expert offers flexibility when formatting different sections of reports. You can turn
each option on or off, or you can use a Boolean condition to do this.
A formula button is located adjacent to most of the options in the Section Expert. The options
on the Common tab of the Section Expert are on or off properties so the formula entered needs
to return a Boolean value. The result of the formula you use for conditionally formatting the
field must return a True/False or Yes/No answer. If the answer is Yes, then the formatting
option is applied. If the answer is No, then the formatting option is not applied.
In the option on the Color tab is an Attribute property. An Attribute property allows you to
have a number of alternatives attributes.
The ability to apply formatting to sections conditionally greatly increases the power and
flexibility of reporting. You can even conditionally apply background colors to sections.
For example, you may have a standard sales report with customer information in the Details
section. For customers with a poor track record, those with less than $25,000 in sales, you also
want to include additional information. You could insert a second Details section, place the
optional information in it and format it to only display in the desired situations. The first Details
section, Details a, would have the standard information and would always be displayed. But
for Details b, with the optional information, you would use the Suppress property with a
formula.
Remember you are suppressing a section. Since you want to display the data in Details b only
for customers with poor performance, you must suppress it in the opposite scenario. In this
example, because you want to display customers who had less than $25,000 in sales, you want
to suppress those customers with sales higher than $25,000 using the formula {Customer.Last
Years Sales} > 25000.

150

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

After completing this unit, you will be able to:

To format sections conditionally


1. Enter any data necessary into the section you want to format.
2. From the Report menu, click the Section Expert command.

For internal use by CSC only

For internal use by CSC only

The Section Expert dialog box opens.

3. In the Section Expert dialog box, select the section you want to conditionally format.
4. Choose the Common or Color tab.
5. Click the Formula button to the right of the section property you want to set.
The Format Formula Editor dialog box opens.
6. Enter the conditional formula to apply the attribute formatting.
7. Click Close on the toolbar to exit the Format Formula Editor, and then click OK.
8. Preview your report.

Creating new sections


By default, every Crystal Report has five sections. For basic report writing these five sections
are sufficient. More complex reports may require more sections. You can create additional
sections using one of three methods: insert via the Section Expert, splitting a section, or using
the Insert Section Below menu option.

To insert a section using the Section Expert


1. Click Section Expert on the Expert Tools toolbar.

Using Report SectionsLearners Guide

151

The Section Expert appears with a list of all the sections in the report. When there are more
than one of any kind of section, the sections are lettered A, B, C, and so on.
Note: The program enables only those options (free form, new page before, and so on) that
apply to the highlighted section.
2. Highlight the section you want to insert a section after.
For example, to add another Details section, highlight the existing Details section.

A new section is inserted immediately below the highlighted section.

To split a section
1. Move the pointer over the left boundary of the section you want to split.
2. When the pointer becomes a Section Splitting cursor, click the boundary and drag the pointer
into the section.
3. When a horizontal line appears, drag it up or down to split the section the way you want
it.

To insert a section below


1. Move the pointer to the grey left margin of the section to be immediately above the new
section.
2. Right-click to access the contact-sensitive menu.
3. Click Insert Section Below.
A new section appears below the position of the pointer. The new section is the same type
as the one above it.

152

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

3. Click Insert.

Deleting sections
Once your report has multiple sections of the same type, you have the option to delete sections.
There are two methods for deleting a section:
Using the Section Expert.
In the Design tab or Preview tab.

1. In the Section Expert, select the section you want to delete.


2. Click Delete.
The selected section is deleted.
3. Click OK when finished.

To delete a section without using the Section Expert


1. Move the pointer to the blue left margin of the section to be immediately above the new
section.
2. Right-click to access the contact-sensitive menu.
3. Click Delete Section.
Tip: When you want to delete a section and its contents, use the Delete section option. Any
objects such as fields, formulas, text objects, and so on, within the section will also be deleted.
When a section contains objects and you want to combine the data with data in another
section, use the Merge section option.
Note: The minimum number of sections on a report is five. Some of these sections may be
suppressed or hidden in the Preview tab but there will always be five sections in the Design
tab.

Moving sections
The general order of the five default sections is set and unchangeable. However, multiple
sections of the same type are movable.

To move sections using the Section Expert


1. Click Section Expert on the Expert Tools toolbar.
The Section Expert appears with a list of all the sections in the report. When there are more
than one of any kind of section, the sections are lettered A, B, C, and so on.
Note: The program enables only those options (free form, new page before, and so on) that
apply to the highlighted section.

Using Report SectionsLearners Guide

153

For internal use by CSC only

For internal use by CSC only

To delete a section using the Section Expert

2. Highlight the section you want to move.


3. Click the Up or Down arrow to move the section.
Note: You can only move a section up or down within an area.
Note: The letters that identify the sections describe their relative (as opposed to original) position.
Thus, if you move a C section up, it becomes a B section. It loses its original C designation.

To move sections without the Section Expert


1. Move the pointer to the blue left margin of the section you wish to move.
2. Click the section to make the pointer turn to a section move cursor.
3. Drag the cursor up or down until the section divider is highlighted.
4. Release the mouse button.

Merging sections
You can merge multiple sections of the same type.

To merge sections using the Section Expert


1. Click Section Expert on the Expert Tools toolbar.
The Section Expert appears with a list of all the sections in the report. When there are more
than one of any kind of section, the sections are lettered A, B, C, and so on.
Note: The program enables only those options (free form, new page before, and so on) that
apply to the highlighted section.
2. Move the sections so the two sections you want to merge follow each other in the list.
3. Highlight the top section.

154

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Note: You can also move sections by dragging and dropping them in the Report Designer.

For internal use by CSC only

For internal use by CSC only

4. With Section (B) highlighted, click Merge and Section (C) will be merged with Section (B)
to form one section.

5. Rearrange the objects as needed.

To merge sections without the Section Expert


1. Move the pointer to the blue left margin of the first section to be merged.
2. Right-click to access the context-sensitive menu.
3. Click Merge Section Below.

Creating page breaks


Creating page breaks adds to the readability of your report. Page breaks are created using the
New Page Before and New Page After options in the Section Expert.

New Page Before and New Page After


This option is usually used with Group Headers or Group Footers. This command forces a
page break before or after starting or ending the section you applied the option to, depending
on the option selected. This command can be made conditional by clicking the formula button
then entering a Boolean formula.
For example, your report shows all customers, grouped by region and you want each region
on a separate piece of paper. By applying New Page After to the Group Footer, you get one
region per page. This command can be made conditional by clicking the formula button then
entering a Boolean formula.
Tip: In order to avoid blank pages, use the conditions Not OnFirstRecord and Not
OnLastRecord with New Page Before or New Page After.
To create a title for your report, apply the New Page After to the Report Header, and put all
the items you want on the title page into the Report Header. This command can be made
conditional by clicking the formula button then entering a Boolean formula.

Using Report SectionsLearners Guide

155

To create a page break


1. Open the Section Expert and select the Group Footer that you want to be the last on the
page.
2. On the Paging tab, click the New Page After formula button to access the Formula Editor.
3. Enter the following condition:

Activity: Creating and merging sections


Objective
Enhance a basic employee report using various techniques.

Instructions
1. Open Employee List-1.rpt from the course resources.
2. Below the personal information, add a new details section containing the following company
information:

Position
Extension
Social Security Number (display only the last four digits)
Birth Date (do not display the time)
Hire Date (do not display the time)

3. Insert another details section containing the following emergency contact information:

Name
Relationship
Phone
Address 1
Address 2
City, Region and Postal Code

4. Use labels as necessary to identify fields.


5. Suppress the Report Header and Page Header.
6. Group by the employee's country and city.
7. Insert a new page after each country except the last country.
8. Format the report so that the employee information always remains together.
9. Rearrange the order of the groups so that the Employee ID group is below the City group.
10.Switch the order of the company information and personal information.
11.Save the report as Creating and merging sections.rpt.

156

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Not OnLastRecord

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

Activity: Applying conditional formatting to sections


Objective
Modify the report using conditional formatting.

Instructions
1. Open Creating and merging sections.rpt.
2. In the personal information and contact information areas of the report there is a gap
whenever the Address2 or Emergency Contact Address2 fields contain no information.
Improve the formatting of the report by suppressing the Address2 and Emergency Contact
Address2 fields when they are empty.
3. Format the report so that the contact information area displays only if the Emergency Contact
Relationship value is either Husband or Wife.
4. Save the report as Applying conditional formatting to sections.rpt.

Using Report SectionsLearners Guide

157

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

158

Business Reporting SolutionsLearners Guide

Using group-related functions to format sections


There are group functions that are intended for formatting sections. When using these functions,
section formatting becomes more versatile.
After completing this unit, you will be able to:
Use group-related functions to format sections

For internal use by CSC only

DrillDownGroupLevel
DrillDownGroupLevel returns a number that indicates the group level of the current drill-down

view, or zero if it is not a drill-down view.


For example, if a report has groups on Country and Region, then DrillDownGroupLevel returns
zero in the view without drill-downs. Within the drill-down view for a Country,
DrillDownGroupLevel returns one, and within the drill-down view of a Region,
DrillDownGroupLevel returns two.
To check if you are in a drill-down view, test to see if DrillDownGroupLevel > 0 returns true.
GroupNumber
GroupNumber returns the current group number and creates a field containing the current group

number that you can place on your report. You can use this function in a group selection formula
to print some groups and exclude others.
InRepeatedGroupHeader
InRepeatedGroupHeader returns a Boolean value.

It returns TRUE when a Group Header section is repeated on subsequent pages.


This function is often used to add text to group headers that appear when a group is broken
over more than one page. For example, you may want to add the text: cont. to the group header
when it appears on subsequent pages after the first.
GroupSelection
GroupSelection returns the group selection formula. It inserts the group selection formula for

the report in a formula that you can then use in your report.
You can use this function any time you want to print the group selection formula on the report,
or whenever you want to set something as conditional on the group selection formula.

Activity: Using group-related functions to format sections


Objective
Use group-related functions to enhance a basic employee report.

Using Report SectionsLearners Guide

159

For internal use by CSC only

Using group-related functions

Instructions
1. Open Organizing formatting.rpt.
2. Each employee name should appear with either a blue or purple background (alternate each
color).
3. Save the report as Group functions.rpt.
Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

4. Open Using group-related functions to format sections.rpt.


5. The human resources division would like a separate report that shows all of the cities where
there are two or more employees for a possible carpool.
6. Save the report as Group selection.rpt.

160

Business Reporting SolutionsLearners Guide

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

Using Report SectionsLearners Guide

161

Using section underlay


Up to this point the reports you created are relatively flat in appearance. Using section underlay
you will add another dimension to your report.
After completing this unit, you will be able to:
Use section underlay

For internal use by CSC only

Normally when you place an object in a section the object prints in the section where it is placed.
When you use the Underlay Following Section attribute, the object underlays or is placed
under the following sections. This functionality enables you to display a graph for a group next
to the groups details, display a watermark in the reports background, or use a scanned image
of a form as a guide in setting up a report to print on preprinted forms.
You place the object in a separate section then apply the underlay attribute.
When you use the Underlay option, the section can underlay multiple sections with enough
space to display the data. But a section cannot underlay its sister sections.
A Page Header section can underlay all sections up to, but not including, the Page Footer.
A Group Header section can underlay all sections, but only up to its matching Group Footer
section.
Therefore, if you underlay the Group Header section and an object in the Group Header section
is wider than the entire Details section, the program will create white space between the end
of the Details section and the beginning of the Group Footer section.

To underlay sections
1. Place only the object you want to underlay in a section.
If you want the objects in this section to be printed next to objects in the following sections,
you may also want to move the objects left or right.
2. From the Report menu, select the Section Expert command.
The Section Expert dialog box appears
3. Select the section you want to underlay.
4. Select the Underlay Following Sections check box.

162

Business Reporting SolutionsLearners Guide

For internal use by CSC only

Using section underlay in a report

For internal use by CSC only

For internal use by CSC only

5. Click OK.
6. Preview your report.
The section formatted to underlay is now under the following section(s).
Your report should look like this:

Using Report SectionsLearners Guide

163

If you highlight an area in the Section Expert, the formatting applies to each section within
that highlighted area. If you select a section, the formatting applies to only that section.

Activity: Using underlay in a report


Objective

Instructions
1. Open Using group-related functions to format sections.rpt.
2. Format the report so that the employee images from the Employee.Photos field display to
the right of the employee information.
3. Save the report as Using underlay in a report.rpt.
Your report should look similar to this:

164

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Use underlay to solve field problems.

Formatting with multiple columns


Another way to change the look of a report is to use multiple-column formatting to give the
report an appearance similar to newspaper columns.
After completing this unit, you will be able to:
Use multiple-column formatting

For internal use by CSC only

Instead of having your data print straight down the page, you can set up multiple columns
and have the data flow from column to column.

To create a multiple-column report


1. Open the report you want to format with multiple columns.
2. On the Report menu, click Section Expert.
Tip: Another way to do this is to click the Section Expert button on the Expert Tools toolbar.
3. In the Section Expert, highlight Details, and then select Format with Multiple Columns.
A Layout tab is added to the Section Expert.
4. Click the Layout tab and set the Width you want your column to be.
Keep in mind the width of your paper when deciding your column width. For example, if
you have three fields in your Details section, and they take up a total of four inches of space,
limit the width of the column to under four and a half inches so that all the field information
can be seen.
5. Set the Horizontal gap and/or Vertical gap you want to maintain between each record in
your column.
6. In the Printing Direction area, choose a direction.
7. If the report you are formatting contains grouping, select Format Groups with multiple
columns.
8. Click OK.
When you preview the report, you will see that the field headers appear only for the first
column. To have field headers for the second column, insert a text object.

Using Report SectionsLearners Guide

165

For internal use by CSC only

Using multiple-column formatting

Activity: Formatting using multiple columns


Objective
Create a report that uses multiple columns. Your users are used to printing mailing labels
using their printer. They want to print their customer list on mailing labels three across to
fit the adhesive labels.

1. Create a new report using the Customer table from the Xtreme Sample Database.
2. Insert one text box in the Details section that includes:

{Contact First Name} {Contact Last Name}


{Address1}
{Address2}
{City}, {Region} {Postal Code}

Suppress the Address2 field whenever it contains no value.


3. Format the address label to fit three across, and proportional for printing.
4. Remove unnecessary sections.
5. Save the report as Formatting for multiple columns.rpt.
Your report should look similar to this:

166

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Instructions

Quiz: Using report sections


1. True or False. Using the Section Expert, every section has the ability to change color.
2. True or False. New Page Before and New Page After must be enabled (check boxes selected)
in order to be conditionally used.
3. True or False. GroupNumber requires a group in order to use it.

For internal use by CSC only

For internal use by CSC only

4. To have one section on top of another is called:


a. Overwrite
b. Overpass
c. Underlay
d. Underneath
5. True or False. Multiple-column formatting is only available for the Details section.
6. True or False. Every Crystal Report has a minimum of five sections.
7. True or False. Any sections can be merged.
8. True or False. Sections must be merged using the Section Expert.

Using Report SectionsLearners Guide

167

Lesson summary
After completing this lesson, you are now able to:

Use sections
Use group-related functions to format sections
Use section underlay
Use multiple-column reporting

For internal use by CSC only

For internal use by CSC only

168

Business Reporting SolutionsLearners Guide

Lesson 9

Building Specialized Reports


Lesson introduction
In this lesson you will start to combine some of the concepts you have learned.

For internal use by CSC only

For internal use by CSC only

After completing this lesson, you will be able to:


Use the Running Total Expert
Create a form letter
Add a hyperlink to a report
Use Dynamic Graphic Locations
Build a report with alerts
Build a top N report
Integrate a Flash SWF into a Crystal Report

Building Specialized ReportsLearners Guide

169

Using the Running Total Expert


Running total fields are similar to summary fields but allow more control over how the total
is calculated and when it is reset.

Create a running total field using the Running Total Expert


Place a running total field in a report
Choose the appropriate evaluation and reset options
Create a conditional running total

Creating a running total field using the Running Total Expert


A running total field is created with the Running Total Expert. The Running Total Expert
creates a running total field by asking you to select a field to summarize, the summary operation
to use, a condition upon which to base the evaluation, and a condition on which to reset the
evaluation.

Note: A running total field can be used to calculate a total on any database or formula field. A
running total field cannot be used to calculate the total of a print-time formula.

Running totals are totals that are displayed generally on a record-by-record basis. They total
all records (in the report, in the group, and so on) up to and including the current record.
The most basic form of running total is a single running total maintained throughout a list. For
example, if your first three records have values of 2, 4, and 6, the running total for each of the
three records would be:

170

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

After completing this unit, you will be able to:

Running Total

2=0+2

6=2+4

12 = 6 + 6

The following procedure demonstrates a running total using a sum operation, adding each
value to the next. Other operations are available such as average, count, and distinct count.

To create a running total field


1. From the Field Explorer select Running Total Fields, and then click New.
The Create Running Total Field dialog box appears.
2. In the Running Total Name box enter a name, for example, Total Orders.
3. Select the field to be totaled in the Available Tables and Fields box, and use the first arrow
button to move it over to the Field to summarize box.
4. Select sum from the Type of summary list.
5. In the Evaluate section of the dialog box, click For each record.
The running total executes each time this field changes.
6. In the Reset section of the dialog box, click Never.
This gives you a running total that never resets. The running total continues throughout
the report.
7. Click OK to save the running total field.
The program returns you to the Field Explorer dialog box.

Placing a running total field in a report


The calculation of a Running Total field is determined by the settings selected in the Running
Total Expert. However, where you place the running total affects the value that appears on
the report. For example, if you place a Running Total field that evaluates every record and
never resets (a grand total) in the Report Header, only the value of the first record appears.
Placing the same Running Total field in the Report Footer returns the desired value. The Running
Total field is properly calculated in both cases, but it is displayed too soon in the first case.
The following table summarizes the records that are included in the calculation when a running
total is placed in various report sections. These examples assume the running total is not reset.

Building Specialized ReportsLearners Guide

171

For internal use by CSC only

For internal use by CSC only

Values

For internal use by CSC only

The first record in the report

Page Header

All records up to and including the first


record on the current page

Group Header

All records up to and including the first


record in the current group

Details

All records up to and including the current


record

Group Footer

All records up to and including the last


record in the current group

Page Footer

All records up to and including the last


record on the current page

Report Footer

All records in the report

To place a running total field in a report to create a grand total


1. From the Field Explorer, click the running total field.
2. Drag the running total field to the Report Footer.
Tip: If you want to see the values of the running total incrementally also place the running
total field in the Details section.

Choosing evaluation and reset options


When creating a running total there are two options that must be set. They are Evaluate and
Reset.

Choosing an Evaluate option


The evaluation options determine which records are included in the value represented by the
running total field:
For each record
Use the For each record option to have your running total evaluate each record in a field.
On change of field

172

Business Reporting SolutionsLearners Guide

For internal use by CSC only

Report Header

Use the On change of field option to have your running total perform its evaluation only
when a specified field has changed.
On change of group
Use the On change of group option to have your running total perform its evaluation only
when a specified group has changed.
Use a formula

Choosing a Reset option


The reset option determines when to reset the running total values to zero:
Never
Use the Never option to lock your running total field. Your running total performs its
calculations on that field throughout the entire report.
On change of field
Use the On change of field list to have your running total reset when a designated field
changes.
Note: Use the Add button (>) to copy a field from the Available Tables and Fields list to
the On change of field list.
On change of group
Use the On change of group list to have your running total reset when a designated group
changes.
Use a formula
Select the Use a formula option to have your running total use a formula to determine when
to reset.

Creating conditional running totals


There may be times when you have a list of values, and you only want to subtotal some of the
values in the list. For example:
You have a list that contains both Canadian and U.S. customers.
You want to keep customer records sorted alphabetically based on customer name.
You do not want to break the data into groups based on the country.
You want a total of the values from just the Canadian records.
You also want a total of the values from just the U.S. records.
To accomplish this, create two running totals, one to keep a running total of the U.S. records,
and one to keep a running total of the Canadian records.
USTotal

Building Specialized ReportsLearners Guide

173

For internal use by CSC only

For internal use by CSC only

Select the Use a formula option to have your running total use a formula when performing
its calculations.

Maintains a running total of the U.S. records.


CanadaTotal
Maintains a running total of the Canadian records.

To create a conditional running total


1. From the Field Explorer select Running Total Fields, and then click New.
For internal use by CSC only

2. In the Running Total Name box enter a name, for example, Total Orders.
3. Select the field to be totaled in the Available Tables and Fields box, and use the first arrow
button to move it over to the Field to summarize box.
4. Select the appropriate type of summary from the Type of summary list.
5. In the Evaluate section of the dialog box, click Use a formula, and then click the Formula
button.
The Formula Workshop appears with Running Total Conditional Formula active.
6. Enter a formula in the Formula box.
7. When the formula has the correct syntax, click Close.
You return to the Create Running Total Field dialog box.
8. In the Reset section of the dialog box, click Never.
9. Click OK to save the running total field.
The program returns you to the Field Explorer dialog box.
10.Place the running total field in the Details section of your report.
11.Preview the report to see the results.

Activity: Using the Running Total Expert


Objective
Use the Running Total Expert to create a running total on an existing report.

Instructions
1. Open Running totals-1.rpt.
2. Create a running total called RT Grand Total that calculates the Grand Total for all order
amounts.
3. Create a running total called RT Subtotal that calculates the subtotal for order amounts for
each customer.
4. Create a running total called RT Count that counts the total number of orders in the report.

174

Business Reporting SolutionsLearners Guide

For internal use by CSC only

The Create Running Total Field dialog box appears.

5. Create a running total called RT Conditional Count that counts the number of orders greater
than $5000.
6. Add appropriate bolded labels for each running total field.
7. Insert identical summary objects to confirm the RT Grand Total, RT Subtotal, and RT Count
amounts are correct.
8. Save the report as Using the running total expert.rpt.
Your report should look similar to this:
For internal use by CSC only

For internal use by CSC only

Building Specialized ReportsLearners Guide

175

Creating a form letter


Form letters are an example of how flexible and powerful your reports can be with Crystal
Reports. You can create any variation of a form letter required.
After completing this unit, you will be able to:

Planning and creating a form letter


When planning to build a form letter, keep in mind that it is usually only the body of the report
that has to change. The body of the report is where the customized message is placed. When
approaching a form letter, plan standard headers and footers and plan different bodies to
accommodate customized messages.
You can use text objects to create the body of your form letters. You can combine text and
database fields in text objects, so it is easy to customize each individual letter. If you want a
letter that provides different results in different circumstances, you need to use conditional
messages.
For example, you may want to send a thank you message to your valued distributors and a
letter of encouragement to your struggling distributors. In such a situation you would create
two different text objects (one for the thank you letter and one for the encouraging letter). You
would then format the report so each distributor receives the appropriate message in the letter.
Tip: When creating multiple-text objects, you may want to take advantage of the copy and paste
commands. You can copy and paste the original text object and then modify it as required.

If you are embedding database fields into a multiple-line text object, you may find that blank
lines appear in the text object if some of the database fields do not contain values. For example,
you might have a text object that contains address information from a database. Some addresses
have two lines; others may only have one. To conditionally suppress this blank line, use
Suppress Embedded Field Blank Lines from the Format Text option from the shortcut menu.
If a database field that contains no values is placed alone in a section on a report, you can
conditionally suppress the entire section by using the Suppress Blank Section option.

To create the body of a form letter


1. Begin with a new report.
2. Insert a text object into the Details section.
3. Format the text object as Can Grow.
4. Stretch the text object horizontally to the width of the page.
5. Double-click the text object.

176

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Plan and create a form letter


Use conditional messaging in a form letter
Add a picture to a form letter

6. Enter text, database fields and other information into the text object.
This section is the body of your letter.

To create additional messages


1. Insert an additional Details section.
2. Repeat steps one through five from the To create the body of a form letter procedure.
For internal use by CSC only

4. Preview your report.


At this point, both text objects will be displayed for each record.

Using conditional messaging in a form letter


Currently, you have each text object displaying for each record. To have only the appropriate
message for each distributor, you need to conditionally format each of the Details sections.
For example, if Details a is the thank you message, you want to ensure it is printed for all good
customers and that Details b, which is the encouraging letter, is printed for all customers with
poor sales.

To display conditional messages in form letters


1. Select the Section Expert button from the toolbar.
The Section Expert dialog box opens.
2. Select the section that contains the text object you want to conditionally display.
3. Click the Formula button next to the Suppress (No Drill-Down)check box.
The Format Formula Editor dialog box opens.
4. Create a formula that suppresses the text object in all circumstances in which you do not
want it displayed.
5. Click Save and Close on the toolbar to exit the Format Formula Editor.
6. Repeat Steps two through five for each section that contains a text object you want to
conditionally display.
7. Click OK to exit the Section Expert and then preview your report.
Only one text object is displayed for each record.
You now have the appropriate message displayed for each record. Next, you need to format
the report so that only one letter displays per page. In order to do this, format the report
using the Section Expert, to print one detail area with the appropriate message per page.

Building Specialized ReportsLearners Guide

177

For internal use by CSC only

3. Repeat this process for each additional message.

To format form letters


1. Click Section Expert on the toolbar.
2. Select the Details area.
The Details area is displayed as "Details." If you select Details a or Details b, you are
formatting the Details a or Details b section, not the entire area.

You now have the main body of your report displaying one letter per page. At this point
you can add address information to the page header and format the text objects themselves.

Adding a picture to a form letter


You can quickly create professional looking form letters. For example, you may want to insert
a watermark in the Page Header section and format the Page Header to underlay following
sections. In this way, you could display your companys logo behind the form letter. Or you
could use a DRAFT graphic that prints on each page indicating that the copy is still in draft
format.

Activity: Creating a form letter


Objective
Employ section formatting to build a reusable form letter. The finance department for Xtreme
mountain bikes has a current set of financial reports that they would like enhanced. One of
the reports not only groups their data by Account type, Account Heading, and Account
Name, but also gives monthly Actual and Budget data as well as a Variance of the two. The
finance department would like to enhance this report to display Actual, Budget and Variance
information for multiple months. You want to mail your distributors a letter either thanking
them if they experienced strong sales, or supporting them if they had a poor year. Your
distributor information is stored in the Customer table of the Xtreme Sample Database.

Instructions
1. Create a new report.
2. Create one text box that contains the address information in the page header. Addresses
should be in this format:
{Customer Name}

ATTN: {Contact First Name} {Contact Last Name}


{Address 1}
{Address 2}
{City}, {Region} {Postal Code}

178

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

3. On the Paging tab, select the New Page After End of Section check box, and then click OK.

Note: Address 2 may not always contain a value. Format the report so that there is no gap
when the Address 2 field is empty.
3. Create the Thank You message using one text box in the Details section. Each customer
letter must start on a new page. The message should be in this format:
Dear {Contact First Name},

Sincerely,
Xtreme
4. Create the supportive message in another details section. The message should be in this
format:
Dear {Contact First Name},
Our sales team will be contacting {Customer Name}. We are sure that together we can improve
upon last years sales of {Last Year's Sales}.
Sincerely,
Xtreme
Note: Ensure the last page is not blank.
5. Format the report so the Thank You letter is sent to distributors with sales greater than
$25,000, and all other distributors receive the supportive letter.
6. Suppress any unnecessary sections.
Ensure that the draft.bmp image appears behind each letter.
7. Save the report as Creating form letters.rpt.

Building Specialized ReportsLearners Guide

179

For internal use by CSC only

For internal use by CSC only

We would like to thank {Customer Name}. With total sales of {Last Year's Sales},
{Customer Name} played a significant part in making last year a successful one.

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

180

Business Reporting SolutionsLearners Guide

Adding a hyperlink to a report


Reports often relate to each other. Hyperlinks are an effective way of moving from one report
to another.
After completing this unit, you will be able to:
Create a hyperlink field

For internal use by CSC only

You can select a report object on the Design or Preview tab and create a hyperlink to another
location.
The hyperlink is saved with your report and is available to other users as a way of viewing
additional information.
Note: Crystal Reports also lets you create hyperlinks with Relative URLs, so your web reports
retain independence from their location on any particular server.

To create a hyperlink field


1. Select a report object on the Design or Preview tab.
2. On the Format menu, click Hyperlink.
The Format Editor dialog box appears with the Hyperlink tab active.
3. Click the type of hyperlink you want to create.
The available types in the upper area are:
No Hyperlink
This is the default option. There is no hyperlink associated with the selected report object.
A Website on the Internet
Select this option if you want your report object to be linked to a static web address. Use
the Formula button to create a URL based on a field value. For example, you might enter
the following formula if your Customer Name field contained information that would
create a series of meaningful URLs:
"http://www." + {Customer.Customer Name} + ".com"

Current Website Field Value


Select this option if you want the program to create a hyperlink out of the field you
selected. The field must be stored as a proper hyperlink in your data source.
An E-mail Address
Select this option if you want to create a mailto address from the field you selected.
Use the formula button to create an address based on a field value.
A File

Building Specialized ReportsLearners Guide

181

For internal use by CSC only

Creating a hyperlink field

Select this option to create a hyperlink to a file on a specific computer or networked


computer. Use the formula button to create a file path based on a field value.
You can also use a hyperlink of this type to run an executable file with a command-line
parameter. Enter the path and application name, and follow it by the parameter for the
command.
Current E-mail Field Value

Note: Not all hyperlink types are available at all times. The object you select and its
location on the report determine which types are available.
4. After you have chosen a hyperlink type, enter the appropriate hyperlink information (the
URL of a website, for example).
5. Click OK when you are finished.
The hyperlink is inserted as appropriate. Click the hyperlink on the report to go to the
website, send an email, and perform other tasks.

Activity: Adding a hyperlink to a report


Objective
Add and format a hyperlink on a report. The Xtreme Bike Company needs a quick way to
email their customers and visit their respective websites.

Instructions
1. Create a new report using the Customer table in the Xtreme Sample Database.
2. Create a Customer Name column formatted as Last name, First name.
3. Sort the list by last name.
4. Create a website link using this format:
www.{Customer Name}.com

5. Create an email list using this format:


{Contact First Name}.{Contact Last Name}@{Customer Name}.com

6. Format the email and website fields so there are:


No double periods (..).
No spaces.
No special characters (commas (,), apostrophes ()).
7. Place the fields in this order: customer name, email, website.
8. Test each hyperlink.

182

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Select this option if you want the program to create an email hyperlink out of the field
you selected. The field must be stored as a proper email address in your data source.

9. Save the report as Adding hyperlinks to a report.rpt.


Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

Building Specialized ReportsLearners Guide

183

Using dynamic graphic locations

A dynamic static OLE object is a picture or metafile that you access in Crystal Reports by use
of a file path or URL. Typically, you use this option when you have the path to your pictures
or metafiles stored as a string field in a database (that is, you do not have the actual objects
stored in the database). You can also use this option when you have pictures or metafiles stored
on a network share, and you know these objects change occasionally.
The functionality of these dynamic static OLE objects (or dynamic graphics) is created in Crystal
Reports through the use of a conditional formatting formula that allows you to link to static
OLE objects by reference.
After completing this unit, you will be able to:
Insert a linked object
Work with linked objects

Inserting a linked object


First insert a static image and then convert it to a dynamic object.
This feature is activated when you refresh your report data. You may not notice a change in
the static OLE object until you click the Refresh button in Crystal Reports.
When you schedule a report that contains a dynamic static OLE object in BusinessObjects
Enterprise, the instances that are created contain the version of the static OLE object as it existed
in your Crystal report when you scheduled it. BusinessObjects Enterprise does not update the
object dynamically for each instance.
Reports that use an absolute or a relative path for a dynamic static OLE object are not supported
in a BusinessObjects Enterprise environment for this release. If you plan to publish reports that
contain dynamic static OLE objects to BusinessObjects Enterprise, it is recommend that you
use URL links for your OLE objects.

To insert a static OLE object


1. Open or create a report that you want to insert a static OLE object in.
2. On the Insert menu, click Picture.
Tip: Another way to do this is to click the picture button on the Insert Tools toolbar.
The Open dialog box appears.
3. Select a picture from a directory that you have access to.
4. Click Open.

184

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

You can now place pictures and graphics in a report through a link stored in a database, so
that it is no longer necessary to store images within the database. This feature supports the
common practice of storing images on a web server and storing references to those images in
a database.

5. When the object frame appears, place the picture in your report.
6. Right-click the picture, and notice that the picture is identified as an OLE object on the
shortcut menu.
When you double-click the object, nothing happens. A static OLE object cannot be edited.

1. Right-click the static OLE object that you inserted, and choose Format Graphic from the
shortcut menu.
Note: You begin the process of making a static OLE object dynamic by inserting the object
into your report as usual. This object becomes the default object. If Crystal Reports cannot
find the dynamic reference to the object, it uses the default object instead.
2. In the Format Editor, click the Picture tab, and then click the Conditional Formula button
adjacent to the Graphic Location label.
3. In the Formula Workshop, create the path to your static OLE object.
For example, if your path is stored in a database field, add that field to the formula.
4. Click Save and close to return to the Format Editor.
5. Click OK to return to your report.
6. Click Refresh to update the reference link to your static OLE object.
Note: Consult the Online Help topic Making a static OLE object dynamic for more detail on
why the refresh is necessary.

Working with linked objects


When a linked object is inserted into a report, Windows copies a snapshot of the data (not the
data itself) from a file that already exists. The image of the object is added to your report along
with a reference to the data used to create it. The actual data remains with the original file.
When the object is activated from within a report, the original file is opened inside the application
that was used to create it. Any changes you make directly affect the original file also.
If you want the data in an object to remain available to other applications, and always reflect
the most current changes to the data, link the object to the report. An automatic link is refreshed
from the source file every time the report is loaded. A manual link is refreshed only when you
request it. You can force a refresh, break a link, or redefine the link in the Edit Links dialog
box.
When you have a linked object and you break the link using the Links dialog box, all connections
to the original data in the server document are broken. A linked object in a container application
is merely a representation of that object and a link between the object and the server document.
When you break the link you're left with only the representation, with no relationship to the
original data or to the editing capabilities of the server application. In this situation, Crystal

Building Specialized ReportsLearners Guide

185

For internal use by CSC only

For internal use by CSC only

To make a static OLE object dynamic

Reports turns the object into a static object, a standalone object that can neither be edited using
OLE capabilities nor converted into an editable OLE object.

Activity: Using dynamic graphic locations


Objective

Instructions
1. Open the No graphics.rpt.
Four countries appear in the Group Tree list.
2. In the Group Header insert the sample image canadianflagsmall.jpg from the resource
CD.
A Canadian flag appears in the group header for all four countries.
3. Build a dynamic graphic location formula that formats the report so that each countrys flag
appears in the group header for that country.
Tip: Use the Group name in your formula.
4. Save the report as Using dynamic graphic locations.rpt.
Your report should look similar to this:

186

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Add and format a linked graphic on a report.

Building a report with alerts


Report Alerts are custom messages created in Crystal Reports that appear when certain
conditions are met by data in a report. Report Alerts may indicate action to be taken by the
user or information about report data.

Create a Report Alert


Edit a Report Alert
Delete a Report Alert
View a Report Alert
Reference a Report Alert in a Formula

Creating a Report Alert


Report Alerts are created from formulas that evaluate conditions you specify. If the condition
is true, the alert is triggered and its message is displayed. Messages can be text strings or
formulas that combine text and report fields.
Once a Report Alert is triggered, its not evaluated again until you refresh your reports data.
Because Report Alerts are specific to each report, you decide when to use them and when not
to. They can be useful to point out important information, such as sales that fall above or below
a limit. And the message is created by you, so it can be specific to your data.
You must complete three steps when creating a Report Alert:
1. Name the alert.
2. Define the condition that triggers the alert.
3. Create the message you want to appear when the alert is triggered (this step is optional).

To create a Report Alert


1. On the Report menu, point to Alerts and then click Create or Modify Alerts.
The Create Alerts dialog box appears.
2. Click New.
The Create Alert dialog box appears.
3. Type a name for your new alert in the Name box.
4. Type your alert message in the Message box.
The Message box lets you enter a message to be used as a default. If you want the same
message to appear every time your alert is triggered, type it in the Message box.
If, however, you want to use a formula so the message is customized with data elements,
see the next step.

Building Specialized ReportsLearners Guide

187

For internal use by CSC only

For internal use by CSC only

After completing this unit, you will be able to:

5. If you want to use a formula to create an alert message, click the Formula button to the right
of Message.
6. Type your alert message formula.
For example, if you want to see the message Country is a star performer (where Country
is the name of a specific country), you might create this formula:
({Customer.Country}) + " is a star performer"

The DefaultAttribute function can be used to refer to a message added in the Message
box. For example, if the message in your Message box is is a star performer, your alert
message formula might be:
({Customer.Country}) + DefaultAttribute

This formula relies on the text you type in the Message box; that text becomes the
DefaultAttribute.
Message condition formulas can be created using either Crystal syntax or Basic syntax.
7. Click Condition.
The Formula Workshop appears.
8. Enter your alert condition formula.
Alert formulas can be based on recurring records or on summary fields, but cannot be based
on print-time fields such as running totals or PrintTime formulas. Alert formulas cannot
have shared variables.
If an alert formula is based on a summary field, any recurring fields used must be constant
over the summary field. For example, if you are grouping on Country, Region, and City,
you might create an alert such as:
Sum ({Customer.Last Years Sales}, {Customer.Region})

In this case, your formula can refer to either Country or Region, but not City or Customer
Name since these are not constant.
Note: Alert-condition formulas can be created using either Crystal syntax or Basic syntax.
9. Clear the Enable check box if you do not want the alert to be evaluated.
Otherwise, leave it selected.
10.Click OK to save your alert.
You are returned to the Create Alerts dialog box and your new alert is listed. You can see
its name and status (Enabled or Disabled).
Only enabled and disabled alerts appear in the Create Alerts dialog box. If an alert is
triggered, it is seen in the Report Alerts dialog box.

188

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Note: The result of an alert message formula must be a string.

Editing a Report Alert


If you want to modify an alert, you can edit it.

To edit a Report Alert


1. On the Report menu, point to Alerts and then click Create or Modify Alerts.

Tip: Double-clicking an alert also lets you edit it.


3. Make the changes you want in the Edit Alert dialog box.
4. Click OK to save your changes.
Note: If the alert has already been triggered, editing it removes it from the Report Alerts dialog
box.

Deleting a Report Alert


If you no longer need a report alert, you can delete it.

To delete a Report Alert


1. On the Report menu, point to Alerts and then click Create or Modify Alerts.
2. In the Create Alerts dialog box, select the alert you want to delete and click Delete.
The selected alert is removed from the Create Alerts dialog box.
Note: If the alert has already been triggered, deleting it removes it from the Report Alerts dialog
box as well.

To delete a Report Alert


1. On the Report menu, point to Alerts and then click Create or Modify Alerts.
2. In the Create Alerts dialog box, select the alert you want to delete and click Delete.
The selected alert is removed from the Create Alerts dialog box.
Note: If the alert has already been triggered, deleting it removes it from the Report Alerts dialog
box as well.

Viewing Report Alerts


You can view triggered Report Alerts by:
Refreshing your report's data.
Selecting Triggered Alerts from the Alerts submenu of the Report menu.

Building Specialized ReportsLearners Guide

189

For internal use by CSC only

For internal use by CSC only

2. In the Create Alerts dialog box, select the alert you want to edit and click Edit.

Note: If you want to view alerts when report data is refreshed, you must select Display Alerts on
Refresh on the Reporting tab of the Options dialog box (this option is also available on the Report
Options dialog box).

To view Report Alerts


1. On the Report menu, point to Alerts and then click Triggered Alerts.

2. Select the alert whose records you want to see.


3. Click View Records.
A new report tab opens showing the report record(s) that triggered the alert. If the record
is hidden, the records group is shown but drill-down is not performed.
Note: If you select more than one triggered alert before clicking the View Records button,
Crystal Reports generates the results by performing a Boolean And operation on the selected
alerts.
4. To return to the Report Alerts dialog box, click the Preview tab.
5. Click Close to remove the Report Alerts dialog box.

Referencing Report Alerts in formulas


Alerts can be referred to in formulas. Any formula that references an alert becomes a print-time
formula.
The following functions are available:
IsAlertEnabled( )
IsAlertTriggered( )
AlertMessage( )
These functions behave the same as alerts created in the Create Alerts dialog box:
IsAlertTriggered("AlertName") is true only for the records on which the alert is triggered
AlertMessage("AlertName") displays the message for a record when the alert is true.
Because alerts are not field objects (you cannot drop them into the report), alerts are represented
differently from report fields in the Formula Workshop. In the Functions tree, you'll see an
Alerts heading where the functions themselves appear. Available alerts are listed by name
below that.

190

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

The Report Alerts dialog box appears.

Activity: Building a report with Report Alerts


Objective
Build a report using alerts to notify the report of a defined condition. Your users want a
report to alert the sales reps to regions with two or fewer customers.

Instructions
For internal use by CSC only

For internal use by CSC only

1. Create a new report using the Customer table from the Xtreme Sample Database.
2. Show the customer names, city and last years sales amount.
3. Group by region for only USA.
4. Create an alert that shows the regions with two or fewer customers.
5. Save the report as Creating a report with alerts.rpt.
When refreshed, your report should look similar to this:

Building Specialized ReportsLearners Guide

191

Building a top N report


Creating a top N or bottom N report is a method of group selection that lets you see the
outstanding data at the top or bottom of the data scale.
After completing this unit, you will be able to:

Creating a top or bottom N report


At times, you might want to show only the top or bottom groups or percentage values in a
report: the fastest selling product lines, the countries that account for the top 25 percent of sales,
the states that generate the most orders, and so on. Because this kind of selection is so popular,
the program includes the Group Sort Expert for setting it up easily.
There is one other element to consider when setting up top N: what to do with all the records
from other groups that do not fit the top N or bottom N criteria you have set. You need to
decide whether to eliminate those records from your report entirely or to lump them all together
into a single group. The program enables you to choose either option.
Note: A report must contain a summary value and a group in order to be able to perform a top N
or bottom N selection.
Note: Whenever you are creating a top or bottom N report where N is less than the total number
of records available, any Grand Total values will be incorrect. You must use a Running Total instead
to compensate.

To select the top or bottom N groups


Note: This procedure shows you how to select top or bottom N groups. Top or bottom percentages
work the same way except that you define the percentage value instead of the number of groups.

1. Create a report and summarize the data as desired. When you summarize the data, the
program breaks the data into groups and summarizes each group.
With top N groups, you are instructing the program to display those groups that have
the highest summary values (Top N).
With bottom N groups, you are instructing the program to display those groups that
have the lowest summary values (Bottom N).
2. Click the Group Sort Expert button on the Expert Tools toolbar.
The Group Sort Expert appears with a tab for your group.
Note: If you have multiple groups, the program displays a tab for each of the groups.
3. Choose Top N or Bottom N from the first drop-down list.
4. Choose the summary that you want to base your selection on from the summary drop-down
list on the right.

192

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Create a top or bottom N report


Create a parameterized top or bottom N report

The summary drop-down list is for those cases in which you have multiple summaries
within a single group section. For example, in an orders report, you might sum and average
the orders for each customer and then display both the sum and the average in the same
group section. In such a case, you would select the sum or the average from this drop-down
list.
5. In the Where N is text box, enter the number of groups you want to display. For example:

Note: If using Top N or Bottom Percentage you define the percentage values instead of
the number of groups.
The records returned are a complete set of records for the group or groups that add up to
that percentage.
For example, suppose you had the following groups:

Group 1 = 40%
Group 2 = 25%
Group 3 = 15%
Group 4 = 10%
Group 5 = 10%

If you set the Bottom Percentage to be 20, you get only the records for Group 4 and Group
5.
If you set the Top Percentage to be 25, you get all the records for Group 1.
6. Click the Include Others, with the name check box and enter a name if you want to group
all the other records into a single group.
7. Select Include ties to accommodate groups whose summarized values are equal.
For example, suppose you had the following groups:

Order 1 = 100
Order 2 = 90
Order 3 = 80
Order 4 = 80

If you set your Top N to three, but you do not select Include ties, your report will show
Order 1, Order 2, and Order 3.
If, in the same scenario, you do select Include ties, your report will show Order 1, Order 2,
Order 3, and Order 4 even though N is set as three. In this way, the program accommodates
the equal values of orders 3 and 4.
8. Click OK when finished.
When you run the report, only those groups that you specified are included.

Building Specialized ReportsLearners Guide

193

For internal use by CSC only

For internal use by CSC only

To report on the three fastest selling product lines, set N to be equal to three.
To report on the five least productive sales regions, set N to be equal to five.

Creating a parameterized top or bottom N report


If you want your users to choose their own value for a Top N, a Bottom N, or a top or bottom
percentage, create a parameter to prompt for the value that Crystal Reports can then pass to a
conditional selection formula.
Note: For groups, the top or bottom N value must be between 1 and 32,766.

To select a conditional number of groups or percentage value


1. Open or create the report that you want to use for the conditional value or percentage
selection.
Note: This report must contain a group and summary information.
2. In the Field Explorer, select Parameter Fields, and then click New.
3. Create a number parameter.
4. Click OK to save your parameter.
5. On the Report menu, click Group Sort Expert.
6. In the Group Sort Expert, select the type of group sort that you want.
Choose any option except No Sort or All.
7. Click the Conditional Formula button next to the N or Percentage value field.
8. In the Formula Workshop, type the parameter field that you created in step three.
9. Click Save and close to return to your report.
10.Click OK to save your group sort.
11.When you are prompted to enter a number or percentage, type the value that you want,
and then click OK.
Your report appears with only the number of groups that match the value you entered in
your parameter prompt. To enter a different value, click the Refresh button and choose
Prompt for new parameter values. The groups in your report are refreshed to show the
new value that you entered.

Activity: What information will you see?


Objective
Identify what information you will see based on top or bottom N sorting.
Review the data in the table below and answer the questions.

194

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Note: For percentages, the top or bottom N value must be between 0 and 100.

Instructions:
Score

Joe

5.3

Tom

4.7

Kathy

3.8

Pete

3.8

Bob

3.2

David

3.0

Sue

2.6

Dan

2.6

Kelly

2.2

Linda

2.1

For internal use by CSC only

For internal use by CSC only

Runner

1. Which name(s) will appear when you run a Top 3 report?


2. Which name(s) will appear when you run a Top 3 report including ties?
3. Which name(s) will appear when you run a Top 10% report?

Activity: Building a top N report


Objective
Create a top N report.
The users want to see the most popular delivery services used by their customers.

Instructions
1. Open the report Group sort expert.rpt in the course resources.
2. Show only the top four shippers. Include ties, and do not include Others in the report.

Building Specialized ReportsLearners Guide

195

3. Save the report as Building a top N report.rpt.


Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

196

Business Reporting SolutionsLearners Guide

Integrating Flash
Flash integration allows report authors to embed any SWF file into a report. This feature includes
the ability to pass data from Crystal Reports into SWFs created in Xcelsius.
After completing this unit, you will be able to:

Integrating Shockwave Flash (SWF) objects


Flash technology is a popular way to add animation to web pages. Flash files can be viewed
in a standalone Flash Player, inserted into web pages or inserted into Crystal Reports.
Flash files have a .swf extension. To modify an SWF, you will need the original source file and
a Flash authoring tool.
You can either embed an SWF or link to an SWF in any section of a Crystal Reports report.
When you embed the object, you can bind it to the report, but you may be able to bind to only
a single variable. You can bind to multiple values in a crosstab, but you cannot automatically
extract the values.
To bind to multiple values, you should use an SWF object that has been created with Xcelsius
2008.
When you link to an object, you will see a static representation of the data. If the SWF object
that you link to is updated, you must close and reopen your report to view the changes.
There are restrictions for SWFs created using the Crystal Reports data connection in Xcelsius
2008. Those SWFs can be added to the following sections only:

Report header
Group header
Group footer
Report footer

Note:

You must have Adobe Flash Player 9 installed on your machine to test the functionality of
the Flash object.
To view a report that contains a Flash object, you need a viewer that supports Flash rendering
such as the .Net Webform or the Java DHTML viewers.
Reports that are exported or printed will display the default image that you have set instead
of the SWF object.
The only format that will display SWF objects in exported reports is PDF. However, if the
object contains data binding to the report, the default image is displayed instead of the SWF.

Building Specialized ReportsLearners Guide

197

For internal use by CSC only

For internal use by CSC only

Insert a Shockwave Flash (SWF) object into a Crystal report


Bind data to a crosstab

Adding an Xcelsius SWF object to a report


Shockwave Flash (SWF) files cannot be created within Crystal Reports, but they can be displayed.
The Design tab displays a placeholder image of the SWF, and the Preview tab displays the
actual SWF file.

In the Design view, if you choose to insert an SWF that contains an embedded movie or sound,
you will hear the sound, but you will not see the movie play. This may cause an echo when
you switch to the Preview view.
Consult with your system administrator to find out how to resolve this issue, or check the
Business Objects support site for more information.

To add an Xcelsius SWF object to a report


1. On the Insert menu, click Flash.
The Insert Flash Object dialog box appears.
Note: Use one of the following options as an alternative method for inserting a flash object:
On the Insert Tools toolbar, click the Insert Flash Object button.
Right-click in the report and from the context menu, select Insert Flash Object.
2. Enter the full path for the flash object. If you do not know the exact path, click Browse to
find the desired file.
3. Select either embed or link, and then click OK.
The flash object is added to the report.
4. Drag the object frame to the position where you wish to place the flash object.

Using data binding to bind an Xcelsius SWF object to a report


Data can be sent from a report to an SWF, but not from an SWF to a report. The parameters in
the SWF are extracted to set the name of the parameter and the format of the data, such as cell,
row, or table.
There are three ways to bind data to Flash variables within the SWF object:
Bind to a crosstab in the SWF.
A user interface that is like the crosstab expert allows you to map rows, columns, and
summarized fields to Xcelsius variables.
Bind to an external crosstab.
You can bind data to a crosstab within the report.
Bind to a single value.

198

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Note:

You can bind data to one detail item in the report. Select fields from the tables to bind to
existing variables in the Flash Data Expert.
Note: If a recurring field is selected, only the first instance is sent.

To bind data to a crosstab


1. Right-click the SWF object and select Flash Data Expert.
For internal use by CSC only

For internal use by CSC only

The Flash Data Binding Expert appears.


2. Select a data field and drag it to a row or column of the crosstab.
3. When you have finished adding data fields to the crosstab, click OK.

To bind data to a single value


1. Right-click the SWF object and select Flash Data Expert.
The Flash Data Binding Expert appears.
2. For each variable that is listed, select a field or type a value.
3. When finished, click OK.

Activity: Integrating an Xcelsius Flash file into a Crystal report


Objective
Bind report data into an Xcelsius Flash file.

Instructions
1. Open Flashint_Workshop-1.rpt.
2. Insert the Xcelsius Flash file Simple Pie Chart.swf into the report header.
3. Use the Flash Data Expert to map the {Customer.Country} field to the Flash file's row labels,
and the {Customer.Last Year's Sales} field to the Flash file's data values.
Notice that the values displayed are temporary and may not reflect values from the report.
4. View the report.
You now have a basic Xcelsius chart with data pushed from the report in alphabetical order.
5. Edit the chart to use the Top N option to limit the data sent to the chart to the top eight
countries.
6. Set the Chart Title to Last Year Sales and the Chart Subtitle to by country.
7. Save the report as Integrating an Xcelsius Flash file.rpt.

Building Specialized ReportsLearners Guide

199

Your report should look similar to this:

For internal use by CSC only

For internal use by CSC only

200

Business Reporting SolutionsLearners Guide

Quiz: Building specialized reports


1. In which Report Sections should a Running Total field be placed?
2. Are Hyperlinks in Crystal Reports static or dynamic?
3. When do Alerts run?
4. What must be on a report for Top N or Group Sort to work?
For internal use by CSC only

6. What can you hyperlink to from a Crystal report?


7. How can you create Conditional Form Letters in Crystal Reports?
8. Could the same record be displayed in more than one Alert?
9. When would a Running Total in the Report Footer show a different value than a regular
Grand Total?
10.In which report sections can you insert Xcelsius Shockwave Flash (SWF) objects?

Building Specialized ReportsLearners Guide

201

For internal use by CSC only

5. In the Group Sort Expert, what does Percentage refer to in the Top Percentage option?

Lesson summary

Use the Running Total Expert


Create a form letter
Add a hyperlink to a report
Use Dynamic Graphic Locations
Build a report with alerts
Build a top N report
Integrate a Flash SWF into a Crystal Report

202

For internal use by CSC only

For internal use by CSC only

After completing this lesson, you are now able to:

Business Reporting SolutionsLearners Guide

Answer Key
This section contains the answers to the reviews and/or activities for the applicable lessons.

For internal use by CSC only

For internal use by CSC only

Answer KeyLearners Guide

203

For internal use by CSC only

For internal use by CSC only

204

Business Reporting SolutionsLearners Guide

Quiz: Using the repository and repository data


sources
Page 14
1. What types of objects can be stored in the repository?

For internal use by CSC only

2. Repository tooltips include Author and Description information for text objects and bitmaps.
3. True or False. If an item or folder is deleted from the repository it is permanently removed.
Answer: TRUE
4. When saving text object or bitmap images to the repository, you can use all the following
characters in the object's name:
A) $ * " ! @
B) . # ^ & ~
C) % ! * ^ )
D) ; @ ~ $ *
Answer: C
A) $ * " ! @ <--- includes "
B) . # ^ & ~ <--- includes #
C) % ! * ^ ) <--- Does not include any prohibited characters.
D) ; @ ~ $ * <--- includes ;
5. True or False. Any object stored in the repository can be deleted but those objects must also
be deleted from the report.
Answer: FALSE
6. True or False. All Crystal Reports native drivers support the Add Command feature.
Answer: FALSE
7. Custom functions can be added to the repository through the Formula Workshop.
8. True or False. The Set Datasource Location feature makes it possible to create a query based
on one universe and then apply it to a new universe.
Answer: TRUE

Answer KeyLearners Guide

205

For internal use by CSC only

Answer: Image, Text objects, Custom Functions, SQL Commands, List of Values, and
Universes

Activity: Defining string functions and operators


Page 22

206

Description

Length

A.

Subscript(x[y])

A.

Trim

A.

Right

A.

Not

A.

Replace

A.

x&y

A.

Picture

A.

Instr

A.

Left

A.

IsNull

A.

ToText

A.

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

1. Item

Activity: Defining date and time functions and


operators
Page 31
Description

DateDiff

A.

DateAdd

A.

DatePart

A.

DateSerial

A.

IsDate

A.

Date

A.

Year

A.

Day

A.

Answer KeyLearners Guide

For internal use by CSC only

For internal use by CSC only

1. Item

207

Quiz: Creating formulas


Page 43
1. What will Length(Business Objects) return?
Answer: 16

My Employee no + {Employee.Employee ID}

Answer: No, this will not work. To concatenate different data types the & must be used.
3. What will the following return?
Business Objects[10 to 16]

Answer: Characters 10 to 16 will be returned, which are Objects.


4. What will the following return?
DateAdd(m,1,#11/08/2004#)

Answer: 12/08/2004

208

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

2. {Employee.Employee ID} is a field from the Xtreme Sample Database. Will the following
concatenation work? Why? Why not?

Quiz: Managing reports


Page 60
1. What are the components you might find in the Workbench?
Answer: Projects, Reports, and Object Packages

Answer: To publish reports to BusinessObjects Enterprise you can use the Crystal Publishing
Wizard or the Save As... option from the File menu on Crystal Reports. You can also publish
through the Workbench.

Answer KeyLearners Guide

209

For internal use by CSC only

For internal use by CSC only

2. What are the different ways you can publish Crystal Reports to BusinessObjects Enterprise?

Quiz: Using variables and arrays


Page 74
1. What is the scope of this variable?
numberVar nAge;

2. Rewrite the variable declaration to make it work.


local string sName;

Answer: The datatype must have Var at the end of it, so the declaration should be local
stringVar sName;

3. Rewrite the variable declaration to make it work. Assume the declaration is at the beginning
of a formula that has more than one statement.
currencyVar cSalary

Answer: The semicolon at the end is missing, so the declaration should be currencyVar
cSalary;

4. Rewrite this array declaration to make it work, assuming that the statement is not at the
end of the formula.
global numberVar CustomerID := [345, 894, 938]

Answer:
The word Array and the semi-colon at the end are missing, so the declaration should be
global numberVar Array CustomerID := [345, 894, 938];

5. From the following array, how would you display dog?


local stringVar Array Farm := [sheep, goat, cow, dog, cat];

Answer: Farm[4]

210

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

Answer: No scope has been declared, therefore the variable takes on the default global
scope.

Quiz: Using report templates


Page 86
1. What type of files are report templates?
Answer: Report templates are .rpt files.

Answer: The additional sections on the template are ignored.


3. For templates to be displayed in the Template list, in which directory must they be stored?
Answer: In order for templates to appear in the Template list of the Template Expert they
must be stored in the following directory:
\Program Files\Business Objects\Crystal Reports <n>\Templates

4. How do you create a preview picture for a template?


Answer:
1. Click File and then Summary Info.
2. Check the Save Preview Picture check box.
3. Preview the report.
4. Save the report. As a best practice save the report in the template directory:
\Program Files\Business Objects\Crystal Reports <n>\Templates

5. What are the four types of fields that Template Field Objects can be applied to?
Answer: The four field types are database fields, parameter fields, SQL expression fields
and formulas.

Answer KeyLearners Guide

211

For internal use by CSC only

For internal use by CSC only

2. If the report to which a template is applied has fewer sections than the template what
happens?

Quiz: Building parameterized reports


Page 120
1. What are two locations where parameter fields are commonly used?
Answer: Parameter fields are commonly used in formulas and record selection.

Answer: A parameter field can be identified by French braces and a question mark before
the parameter name. For example, {?parameter_name}.
3. What is the purpose of a default-value list?
Answer: Default values give the user a "hint" as to the type of information to enter in the
parameter prompt. Default values also speed up the process by displaying a list of values
from which to choose.
4. How do you display a single-value parameter on a report?
Answer: To display a single value on a report, create a text object and leave space to insert
the parameter. Insert the parameter in place of text.
5. In an edit mask, what is the difference between using A and a?
Answer: Both enable an alphanumeric character but A requires the entry of a character in
the parameter value where a does not require the entry of a character in the parameter value.
6. If the discrete values A and G are entered as parameter values used in record selection and
the operator used is the equal sign, what records will be returned?
Answer: Only the records that are equal to A and G will be returned.
7. What function(s) would you use to display date ranges on a report?
Answer: Use Minimum and Maximum functions.

212

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

2. What is the syntax notation that identifies a field as a parameter?

Quiz: Summarizing data with crosstabs


Page 147
1. What are the three elements that make up a crosstab?
Answer: The three elements are rows, columns and summary fields.

Answer: Crosstabs cannot be placed in detail sections or page headers.


3. What happens if you attempt to place a crosstab object into a section that does not allow
crosstab Objects?
Answer: Crystal Reports automatically moves the crosstab to the nearest section that accepts
crosstabs.
4. What are the three available chart types when creating a crosstab report using the Standard
Report Wizard?
Answer: The available chart types are bar, line, and pie.
5. What does the Pivot Cross-Tab option do?
Answer: The Pivot Cross-Tab option moves all the row fields to columns and all the column
fields to rows.
6. What Crystal formatting function would be used to conditionally format a field element,
field object, summary or label in a crosstab?
Answer: CurrentFieldValue
7. How would you suppress an empty column in a crosstab?
Answer: Customize Style Tab - Select Suppress Empty Columns check box

Answer KeyLearners Guide

213

For internal use by CSC only

For internal use by CSC only

2. Name two sections that will not accept a crosstab object.

Quiz: Using report sections


Page 167
1. True or False. Using the Section Expert, every section has the ability to change color.
Answer: True

Answer: False. New Page Before and New Page After do not have to be enabled to be
conditionally used. Conditional use overrides absolute use.
3. True or False. GroupNumber requires a group in order to use it.
Answer: False. Create a formula and insert the GroupNumber function. Put the formula
anywhere on the report. If no group exists, it returns a 1 for the first group.
4. To have one section on top of another is called:
Answer:
c. Underlay
5. True or False. Multiple-column formatting is only available for the Details section.
Answer: True
6. True or False. Every Crystal Report has a minimum of five sections.
Answer: True. Create a new Crystal Report. Using the Design tab notice the five sections.
7. True or False. Any sections can be merged.
Answer: False. Only sections of the same type can be merged.
8. True or False. Sections must be merged using the Section Expert.
Answer: False. A right-mouse click in the grey area activates a context-sensitive menu
allowing a merge option of like Sections.

214

Business Reporting SolutionsLearners Guide

For internal use by CSC only

For internal use by CSC only

2. True or False. New Page Before and New Page After must be enabled (check boxes selected)
in order to be conditionally used.

Quiz: Building specialized reports


Page 201
1. In which Report Sections should a Running Total field be placed?
Answer: Running Totals can be placed in Detail, Group Footer, or Report Footer.

Answer: Both. They could be either static or dynamic. Report Designer may enter a specific
hyperlink value (file, email, or website URL) directly in the Format dialog box (static) or
specify that the current value of a field be used as the hyperlink (dynamic).
3. When do Alerts run?
Answer: Alerts run when a report is refreshed.
4. What must be on a report for Top N or Group Sort to work?
Answer: The report must have Groups and at least one summary field by Group.
5. In the Group Sort Expert, what does Percentage refer to in the Top Percentage option?
Answer: Percent of the Total Number of Groups (Count of Group)
6. What can you hyperlink to from a Crystal report?
Answer: You can hyperlink to another report, a file, file location (folder or directory), a
website, or email address.
7. How can you create Conditional Form Letters in Crystal Reports?
Answer: Insert multiple sections with different text for each type of letter, then conditionally
suppress all but one section based on which letter should be sent.
8. Could the same record be displayed in more than one Alert?
Answer: Yes, this is one feature that distinguishes Alerts from Record Selection and
Conditional Formatting.
9. When would a Running Total in the Report Footer show a different value than a regular
Grand Total?
Answer: A Running Total would show a different value when a report uses Top N or Group
Selection formula.
10.In which report sections can you insert Xcelsius Shockwave Flash (SWF) objects?
Answer: You can insert Xcelsius Shockwave Flash (SWF) objects in the Report header, Group
header, Group footer, and Report footer.

Answer KeyLearners Guide

215

For internal use by CSC only

For internal use by CSC only

2. Are Hyperlinks in Crystal Reports static or dynamic?

For internal use by CSC only

For internal use by CSC only

216

Business Reporting SolutionsLearners Guide

Das könnte Ihnen auch gefallen