In “Chapter-12 Working with Data Bars in SSRS” we have created Data Bars in SSRS report. We are going to color these data bars based on certain conditions. For example, if value of “UnitsInStock” column is below 20 then display the bar in RED color else Green Color. Let us enter the below custom code to our report (refer Chapter-7-Working with Expression and Custom Code).
Step-1: Right click below the report area and choose Report Properties to open Report Properties window.
Step-2: Paste the custom code to the “Custom Code” text area as shown in the image.
The Custom code will be.
Public Shared Function BarColor(ByVal StockUnit As Integer) As String
If StockUnit > 20 Then
Step-3: Double Click on Data Bar a “Chart Data” popup will appear and then right-click on the bar and select “Series Properties..” as shown in the image.
In the Series Properties window, select the Fill tab and click the Expression button (fx) as shown in the image.
And in the expression editor enter the below expression as shown in the image and click ok.
Now run the report and see the view. This completes the “Chapter-13-Displaying Colour in Data Bar Based on Condition”.
Chapter-1: Creating a basic Tabular SSRS Report using Report Wizard
Chapter-2 : Report Deployment on SQL Server 2012 Reporting Server
Chapter-3:Opening/Calling the deployed SQL Server Reporting Server report from Asp.net
Chapter-4 Creating SSRS Matrix Report / Cross Tab Report
Chapter-5 Creating a Sub Report in SSRS
Chapter-6: Creating a Drill Down Report in SSRS
Chapter-7: Working with expressions and custom code in SSRS
Chapter-8-SSRS (Reporting Services) Working with Calculated fields
Chapter-9-Sorting of Column and Custom Paging in SSRS
Chapter-10 : Creating and Deploying Web Services for SSRS
Chapter-11 : Creating SSRS Report by consuming Web Service Data Source
Chapter-12 : Working with Data Bars in SSRS