Filtering Data in Crystal Reports

When you run a report in Crystal Reports, you have a lot of latitude as to what goes in, how it’s formatted and organized, and so on. But one consideration that doesn’t always get mentioned is how to leave data out.
Turns out, it isn’t difficult. In fact, the technique is similar to one we find in several other programs which deal with data and databases.


After opening the program, the database and the report in question, the feature that does the filtering is the Select Expert–specifically, the Record part.


Among the logical operators available to us is “Is Not Like” (sometimes seen in other programs as “< >” or “Not Equal To”). This is the one that says “DON’T show me…” whatever it is you want to exclude from a given field, like City.


But the next part is also easy–just a little different. If, let’s say, we want Crystal to show all cities in a shipping list other than Albuquerque (watch your spelling on this one! 🙂 ), we put that name between asterisks, like so: *Albuquerque*.


This means that every record whose city name does NOT include Albuquerque (beginning with, ending with, or containing) will show in the report.


It may seem a little odd at first, to want to exclude information in Crystal Reports, since usually we’re trying six ways from Sunday to figure out how to include information. But don’t forget that panning for gold meant sifting out what you didn’t want, and reducing a sauce involves removing water or other fluid to make it denser and more flavorful.
As a related point, doing Web searches can involve a similar idea. We often use Google to look for things, but the Advanced search capability lets us say, in essence, “Look for this and this but NOT that.” Hardly ever gets used, but it’s always there if we need it. Ditto in Crystal.

Using Character Mapping to Enhance a Crystal Report

It is possible to dress up a report using nothing more than a font and some color. But not in the way you think. There are some specialty fonts installed on a Windows computer know as Wingdings. Each letter is a small picture (like a phone, scissors, knife, etc.) that can be used in a report to enhance the appearance.

The first step in formatting the report is to find the characters you intend to use. They can be found in the Character Map dialog box within Accessories > System Tools or by typing Character Map in Windows Search.

charactermap

Next you will need a formula to determine when a specific character will be displayed.

alternatefont

 

In this example when sales drop below $40,000 a cross will appear otherwise a check mark will take its place. The letters “Q” and “R” represent the values you’ll need in Wingdings2.

We can dress it up even more by conditionally changing the font color.

 

oddevencolor

The final step is formatting the formula font to use Wingdings2. This is accomplished by selecting the Formula object in Design View and opening the Format Editor, going to the font tab and selecting Wingdings2 from the font list.

wingdings2

The finished report now contains a “Cross” or “Check Mark” in red or green where there once was just a capital Q or R.

checksandxs

 

Crystal Reports Performance Information Tool

After designing a report Crystal Reports provides a built-in utility that will allow you to test performance and shine a light on areas where optimization would be beneficial. It is called the Performance Information tool and can be found by selecting Report > Performance Information in the menu.

menu-performance-information

Once opened, the Performance Information dialog box has a tree structure on the left side that provides five sets of information captured by the tool.

performance-information

Report Definition – Information about the reports content: number of fields, number of summaries, Chart objects, Special Fields, etc.

Saved Data – Data captured in the report: number of data sources, total number of records, size of the saved data.

Processing – Processing of the selected report: grouping and sorting on the server, required page count, number of summary values.

Latest Report Changes – Recent changes to the report.

Performance Timing – These values provide the specific benchmark to determine if any modifications have impacted performance: timing to open the document, formatting the first page, number of pages formatted, and the average time to format a page.

To keep track of these pieces of performance data the Performance Information dialog box offers the option to save the information in a separate text file.

performance-information-save

performance-information-saved-text

These saved files can then be used for comparison purposes. What has improved and what had the greatest impact.

performance-information-text

Making “Can Grow” a Global Setting in Crystal Reports

There are a lot of different setting we talk about during our Crystal Reports classes. Much of the information we end up displaying within these reports consists of text, and in our quest to make it fit we end up making constant adjustments to width and height. That is, until we are introduced to the string format option can grow.

With one simple format setting we eliminate the need to make those height adjustments.

Here is what we are talking about. Our example will use a simple group heading to identify the country of origin.

design_view

It looks like this in print preview.

print_preview

We decide to increase the group heading font size from 10 points to 12 points and discover upon previewing that some of the text has been truncated.

cropped_group_text (more…)

Code Hinting in Crystal Reports Formula Workshop

When using Crystal Reports, formulas play a large role in preforming such basic tasks as conditional formatting, selecting records, and general calculations. The code window for all of these tasks is called the Formula Workshop. It is a centralized window divided into five sections; Workshop tree, Field Tree, Function Tree, Operator Tree, and Definition area.

formula_workshop

Normally when you want to create a basic calculation formula such as taking one database field and multiplying it by another database field you will expand your connection object within the Field Tree so you can see all of your available tables. Clicking the plus sign next to each table will reveal all of the fields in that table. You next step is either double-click the field to insert it into the Definition area or left-click and drag it into the Definition area.

The same can be said for inserting functions or operators. The only difference being you would need to expand the categories each function or operator is listed under.

The Definition area offers an interesting code hinting feature I find very useful. If I want to use a particular field from a database table all I need to do is type an opening curly brace in the Definition area and a pop-up tip gives me a list of all my available database tables. Typing the first letter of the table will select it and I can now press the tab key to insert it. As soon as it is inserted another pop-up tip shows a dot and all the fields within that table. Typing its first letter or first few letters will select it and I can now press tab to insert it.

orderdetails

quantity

A wonderfully fast way to get to any function or operator in the Definition area is to use a simple keyboard shortcut. Just press Ctrl + Spacebar and the same pop-up tip will start an alphabetical list of functions and operators. As you type the pop-up tip eliminates anything that does not contain the letters you are typing.

control_spacebar

control_spacebar_typing

As soon as you can see the function or operator you are looking for you can use your up and down arrow keys to select the item you want. Pressing the tab or enter key will insert it.

control_spacebar_more_typing

This can be a real time saver because you do not need to expand the function or operator categories. Just start typing and your code can be inserted.

tab_or_enter

Crystal Reports – Add True Bullets to a List in a Text Object with the CHRW Function

Suppose you want to display a list of items in a text object and you want that list to appear as a bulleted list.  If your list is hard coded (i.e. USA, Canada, Mexico), then you could simply type the character that represents a bullet, like an asterisk, and have your list in no time flat.

Our example will have a bit of static text at the beginning followed by the bullet list.  The static text will read as follows:

“Last Year’s Sales and Suppliers for”

We will follow up the text with a carriage return to ensure the bullet list begins on a fresh row in the text object.  This is where you could type something like the following:

* USA

* Canada

* Mexico

The finished product would look like:

Bullet01

Suppose your list if items is the result of selections made within a parameter and you want to display that user-defined list with bullets.  The first thing you have to realize is that you can’t just place the parameter in the text box and get the list. (more…)

Crystal Reports – Missing Template Preview

When applying a template to a report, it’s often preferred to “peek” inside the template to see what it has to offer prior to applying it to your report; to “take it for a test drive”, as it were.

If you have a vast template library, and many templates are similarly named, it can be of great benefit to see a preview of what you will receive if applied.  The Template Expert provides just such a preview.

Preview01

For those who prefer to create their own templates, and possibly add them to the library, the preview feature may not display if certain prerequisites have not been satisfied. (more…)

Crystal Reports – Importing Values and Descriptions into Parameters

If you are creating a list of choices for a parameter drop-down list, you can acquire the choices from several sources:

  • Manually enter the choices in the list (static and least exciting of all of the options)
  • Append a unique list of choices derived from a field in the database (static)
  • Point to a database field for available existing choices (dynamic)
  • Import items from a text file (static)

Each of the options has their pros and cons.  If you are trying to generate a list that is unlikely to change (like a list of states in the USA) and you need to ensure all options are made available from Day 1, the first option of manually entering all of the choices is the typical approach.

But what if all of those choices exist in another report or file?  In this case, the ability to import list selections has great appeal. (more…)

Crystal Reports Multi-Pass Processing Engine

Crystal Reports uses a three-pass reporting method to generate reports.  A pass is a process that Crystal Reports uses each time the data is read and manipulated.  Depending on the complexity of the report Crystal Reports may make 1, 2, or 3 passes over the data.  This feature allows for complex reporting and formula manipulation.

CRMultiPassModel (more…)

Crystal Reports – Adding a Watermark to a Report

If you have ever looked for the watermark feature in Crystal Reports, you no doubt walked away smothered in soul-crushing despair wondering how Life could be so cruel.

True, there is no official tool in Crystal Reports that adds a watermark to a report, but that doesn’t mean it can’t be done.  Adding a watermark just takes a bit of creativity and a handful of mouse click and keystrokes.

The trick is to add a subsection and underlay the following sections in the report.  The steps are as follows: (more…)

Crystal Reports Clear Recent Reports History

Crystal Reports – Clear Recent Reports History

As with most applications, Crystal Reports maintains a history of the last several reports opened so as to facilitate repeated access.

ClearRecent01

This is a very helpful feature, but there comes a time in every report user’s life when they just want to clear the list and start clean.

Many applications contain a mechanism that allows the user to clear either individual entries or empty the entire list.  Sadly, Crystal Reports contains no such feature. (more…)

Crystal Reports Training Courses

Crystal ReportsSkillForge offers a comprehensive line-up of Crystal Reports training courses. From introductory to more advanced topics our instructor-led, online and onsite Crystal Reports courses are delivered by expert instructors.

Our Crystal Reports 2011 Training class – like all of our classes –  includes an in-depth course manual – perfect for reference after class, as well as hands-on exercises to practice concepts demonstrated throughout the course.  See all of our Crystal Reports Training classes by visiting our Crystal Reports class page.