Applying Conditional Formatting On Field In Crystal Reports

In this article we will learn conditional formatting on Field in Crystal Reports. Will display salary of each employee and highlight the row if the salary is greater than 25,000 in red.

This article is the second part of my first article.

If you haven’t had a look at the first, then please go through the previous article: Step By Step Creating Grouping In Crystal Report

Step 1: Create a new Table Salary as in the following:

  3. GO  
  7. GO  
  9. CREATE TABLE [dbo].[Salary](  
  11. [EmpId] [intNULL,  
  13. [Salary] [numeric](18, 2) NULL  
  15. ON [PRIMARY]  
  17. GO  

We already created 2 tables in my first article which is Employee and Department. So now we have 3 tables, [1] Employee [2] Department and [3] Salary,


Step 2: Now open the Crystal Report, go to Field Explorer, right click and select Database expert like the following screen:

Step 3: from the database Expert select the Salary table and click on ‘>’ button and click ‘OK’ Button,

Step 4: Now we have Salary table. Go to Links tab, give a link to Employee table and Salary table on EmpId field like the following screenshot.

Step 5: Now we have salary table in Field Explorer


Just Drag and Drop Salary field in Details Section of Crystal Report,
Step 6: Now go to Crystal Reports tab, Report and select Section Expert,
Step 7: Go to details section and click on color tab, 

Step 8: Click on the highlighted button, this will open Formula Workshop,

Step 9: Write your condition here like the following:

if {Salary.Salary} > 25000 then




(If the salary is greater then 25000 then highlight the row with red color else silver color),


That’s it! Just check the formula by pressing Alt + C for checking for errors like the following screenshot,


Step 10: Save the report and click on Main Report Preview,

Selary image 
Here we displayed employee records in red if the salary is greater than 25,000, else highlight in Silver color.
I hope you liked this article.