Join Curt Frye for an in-depth discussion in this video Highlighting records, part of Crystal Reports 2013 Essential Training.
Almost every report contains certain rows of information that are more important than others. In this movie, I will show you how to highlight those rows within the body of the report. This is a very basic report. It only contains four fields. It has the order number. The representative who made the sale. The state the order came from, and the amount of the order. What I'd like to do is highlight rows that meet a certain criteria. If you've worked in Excel with conditional formats, then you will find the concepts that I explain here to be very familiar.
I'd like to highlight the order numbers of any orders above a certain value. So, I'll right click a value in the order number field, and then from the shortcut menu that appears, click Highlighting Expert. Doing so displays the Highlighting Expert dialogue box. Now I can click new to create a new rule. When I do, a new condition appears in the Item list. And then I can use the controls over in the item editor section of the dialogue box to define my rule. The first thing I need to do is to tell Crystal Reports which field to look at, so I'll click the value of control, and then I can select the field that I want, and in this case, it is Order Amount.
Next I can select the comparison operator. So what I want to do is creat a rule that highlights in green, any order of more than $750. So I need a greater than rule. So I click the second control and click Is greater than. Then in the value box I can type in the value that I want for the comparison. And that is 750. And you can see that the condition I've created has been updated here in the Sample panel. And now I can set the appearance for any rows that meet the criteria.
So I can change the font style if I wanted to. Such as making it Italic or Bold or both. I could also add the font color, make it any one of the colors available there. But what I'd like to do is change the background color, and, as I said, I'd like to select green. So I'll click the Background Color control and, from the list that appears, click Green. That's all I want to do for the moment so I'll click OK. And doing so applies the rule and you can see that for any row where the order amount is more than $750, the order number is highlighted in green.
Now, I want to go back into the Highlighting Expert to add more rules and possibly play around a little bit. So, I'll right-click. Value in the order number field and click Highlighting Expert, and my rule is still there. I want to add a new rule. So I'll click New. And this rule will highlight in yellow any row that has an order amount of more than $1000. So I'll move fairly quickly through sets since it's basically the same as what we did before with this rule. Value of order amount is greater than and I'll make it $1000.
And I want to change the background color to yellow. So I'll just scroll down and there is yellow. And I'll click OK. And the rule is created. Now one thing to notice, is that none of the rows are actually highlighted in yellow, even though both row three and row five have values that are greater than $1000. So why did that happen? Well, let's go back in. So right click control in the order ID field, and click Highlighting Expert. The first thing you need to know is that Crystal Reports evaluates the order of the rules from the top to the bottom.
And also, very important, as soon as it finds a rule that a row fits, it stops checking. So in this case even though many of the rows have values greater than 1000, in the order in that field, Crystal Reports never gets to them because it finds that the values are also greater than 750, applies to this format and stops. So what you want to do is order your list so that the most restrictive conditions are on top. If you create your rules in the order that I did Then all you need to do is change their priority.
So for example if I want to move the first rule down I can click it and then click the Move Down button or if equivalently I wanted to move the second row up I could click it and click the Move Up button. So I just did that now my rules go from most restrictive. Greater than 1,000 to least restrictive which is greater than 750 and I can click OK. And when I click away you see that the formatting has been applied properly. If I want to edit or remove a rule all I need to do is go back into the Highlight Expert And then I can click a rule to edit it.
So, for example, if I wanted yellow to be greater than $1250, then all I need to do is to edit that value. And then save my change. And you'll notice that the few other rows that were yellow are now green. And if I go back in to delete a rule, I can right-click, Highlight Expert, and then click the rule that I want to delete, and then click the Remove button, and when I click OK, my changes are saved. As with any other type of formatting, it's easy to go overboard on the highlighting.
Just like the textbooks you highlighted in school, a little bit goes a long way when it comes to emphasizing important ideas in a document.
Author Curt Frye shows you how to define and manage reports, create and delete sections, and summarize and visualize data with charts. Plus, learn how to focus your analysis with selections, subreports, and cross tabs; export report data; and connect to external data sources.
- Creating a report
- Linking to a data source
- Adding fields to a report
- Creating sections in a report
- Sorting, grouping, and summarizing data
- Applying a template
- Applying formats to date fields and other report controls
- Managing images and drawing objects
- Creating charts
- Selecting records
- Using formulas
- Adding subreports
- Exporting report data