Conditional Formatting Using Data to Drive the Look of a Report

Up to now, the focus has been on static formatting. The next step is to apply formatting based on the data that is being returned from a field or even applying formatting on one field based on the value of another.

Conditional formatting relies on formulas. Because the formula language is extensive, complex statements can be created. For this chapter you use relatively simple examples.

The simplest way to add conditional formatting is to use the Highlighting Expert. This feature enables you to apply font face and font color changes to database fields based on their values.


Almost every formatting option can be conditional. To determine which ones are conditional, look at the x+2 button next to the option in the Formatting Editor dialogs.

If a formatting option has already been set to a conditional format, the button appears with red text. Otherwise, it appears as blue text.


Applying Formatting from Another Field

  1. In Design view, right-click the Contact Last Name field, choose Format Field, and then navigate to the Font tab and click the formula button to the right of the Color drop-down. This opens the formula editor, driving your font color choice.
  2. Enter the following formula:

     SELECT {Customer.Last Year's Sales}
    CASE 0 TO 1000: crRed
    CASE 1001 TO 100000: crYellow
    CASE IS > 100001: crGreen;


    Here you specified a color as the result of the case expression because the formula controlled color. In cases where the formatting option is Boolean (that is, either you turn the feature on or off) there is an assumed IF statement, and all you have to do is enter the condition (for example, {table.field} > 100 ). Entering a full IF statement in cases like this causes an error.

  3. Refresh the report by pressing F5 while you're in the Preview tab. Now you see red, yellow, and green last names depending on the amount of last year's sales for that person (see Figure 9.9).

    Figure 9.9. Conditional highlighting based on another field.

  4. Save the report as chap9_5.rpt.

Crystal Reports in the Real World Advanced Charting

Nothing enables users to visualize data better than a chart. With a glance, charts enable users to see relative distribution, peaks, and valleys of values. This section describes how to use charting in creative ways. The following creates a report that charts the sum of sales and distribution of customers by country:

  1. Open the World Sales Report from

    C:Program FilesCrystal DecisionsCrystal Reports 10SamplesEnReportsGeneral Business

    and stretch the chart so it takes the full width of the page. In the left margin, right-click on the text Group Footer 1 and from the menu choose Suppress.
  2. Right-click on the chart and choose Chart Expert. For Chart Type choose Bar and from the buttons that refine which type of bar chart, choose the lower left option described as Side by Side with 3D (see Figure 9.10).

    Figure 9.10. Choosing a chart type.

  3. Click on the Data tab and the Advanced button. From the list of available fields select Customer.Country and add it to the window below On Change Of. Again, from the list of available fields choose Customer.Last Year's Sales and Customer.Customer Name and add them to the Show Values (see Figure 9.11).

    Figure 9.11. Selecting data for the chart.

  4. Click the Options tab and uncheck the Show Label option. Click OK to close the window.
  5. The bar chart is almost complete. It contains the correct data so it is technically accurate, but because the scale of the values is so different it is unreadable for the user. See Figure 9.12.

    Figure 9.12. Technically accurate but not helpful yet.

  6. Because the scale of the data is significantly different, the chart needs to be broken into two axes. Right-click on the chart and choose Chart Options, Template. Click the Dual Axis check box, and click OK. The resulting chart should look like Figure 9.13.

    Figure 9.13. Chart showing two scales of information.

  7. Finally, a trend line can be added to the chart to show a trend in the data. Right-click on the customer name bar and choose Chart Options, Series. Click the Trend Line tab and add a check to the Show Trend Lines check box and click OK. The resulting chart should resemble Figure 9.14. Save the report as World Sales Report with Charts.rpt.

    Figure 9.14. Chart showing two scales of information and a trend line.


Part I. Crystal Reports Design

Creating and Designing Basic Reports

Selecting and Grouping Data

Filtering, Sorting, and Summarizing Data

Understanding and Implementing Formulas

Implementing Parameters for Dynamic Reporting

Part II. Formatting Crystal Reports

Fundamentals of Report Formatting

Working with Report Sections

Visualizing Your Data with Charts and Maps

Custom Formatting Techniques

Part III. Advanced Crystal Reports Design

Using Cross-Tabs for Summarized Reporting

Using Record Selections and Alerts for Interactive Reporting

Using Subreports and Multi-Pass Reporting

Using Formulas and Custom Functions

Designing Effective Report Templates

Additional Data Sources for Crystal Reports

Multidimensional Reporting Against OLAP Data with Crystal Reports

Part IV. Enterprise Report Design Analytic, Web-based, and Excel Report Design

Introduction to Crystal Repository

Crystal Reports Semantic Layer Business Views

Creating Crystal Analysis Reports

Advanced Crystal Analysis Report Design

Ad-Hoc Application and Excel Plug-in for Ad-Hoc and Analytic Reporting

Part V. Web Report Distribution Using Crystal Enterprise

Introduction to Crystal Enterprise

Using Crystal Enterprise with Web Desktop

Crystal Enterprise Architecture

Planning Considerations When Deploying Crystal Enterprise

Deploying Crystal Enterprise in a Complex Network Environment

Administering and Configuring Crystal Enterprise

Part VI. Customized Report Distribution Using Crystal Reports Components

Java Reporting Components

Crystal Reports .NET Components

COM Reporting Components

Part VII. Customized Report Distribution Using Crystal Enterprise Embedded Edition

Introduction to Crystal Enterprise Embedded Edition

Crystal Enterprise Viewing Reports

Crystal Enterprise Embedded Report Modification and Creation

Part VIII. Customized Report Distribution Using Crystal Enterprise Professional

Introduction to the Crystal Enterprise Professional Object Model

Creating Enterprise Reports Applications with Crystal Enterprise Part I

Creating Enterprise Reporting Applications with Crystal Enterprise Part II

Appendix A. Using Sql Queries In Crystal Reports

Creating Enterprise Reporting Applications with Crystal Enterprise Part II

Special Edition Using Crystal Reports 10
Special Edition Using Crystal Reports 10
ISBN: 0789731134
EAN: 2147483647
Year: 2003
Pages: 341 © 2008-2020.
If you may any questions please contact us: