Tuesday 5 May 2015

How to change Background color in SSRS Report depends on Column

Scenario: In SSRS Report display the Employee data, change the background color depends on Employee id like as follows.

1
background color is Red
2
background color is Green
3
background color is Yellow
4
background color is Yellow
5
background color is Green
6
background color is Red
7
background color is Red
8
background color is Green
9
background color is Yellow
10
background color is Yellow
11
background color is Green
12
background color is Red
-
--

 1, 2, 3 are the Employee ID’s

Solution:
• First you create a report by added Adventure Works database to shared Data sources.
• Right click the folder labelled Reports in the solution Explorer. Select AddàNew ItemàReport.rdl
• In the Report Data section, which should be located to the left side of the report and right-click the folder labelled DataSets à Add Dataset.
• In the Dataset select Use a dataset embedded in my report and write the below query on the box.


SELECT TOP 15 [BusinessEntityID] as EmployeeID
      ,[NationalIDNumber]     
      ,[JobTitle]
      ,[BirthDate]
      ,[MaritalStatus]
      ,[Gender]    
  FROM [AdventureWorks].[HumanResources].[Employee]

• Finally the report in the Preview View shows as follows


Report is ready then changes the background color by following these steps.

• Select the Employee data rows in the Design view and Press F4, the properties window will open.


• In the properties window select Background Color àExpressions , and write the below expression.


• And press OK button.

The Output of Report in Preview as shown below.


Let me know what you think about this article.

1 comment: