SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSRS Color coding


SSRS Color coding

Author
Message
ashish.chaudhari
ashish.chaudhari
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 29
I have to color code values in SSRS reports which are baed on another values for eg a statetotal value should be color coded depending on value of comparative performance value for the state. Can it be done? Has anyone done like this ?

State total comparativeperformance
MH 2.8% 1
CT -1.2% 3
AZ 0,1% 2

The 2.8% should be colored as Green (1)

The -1.2% should be colored as Red (3)

The -0.1% should be colored as yellow (2)
Jack Corbett
  Jack Corbett
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19086 Visits: 14900
Sure you can do this. You would put an expression in the color property (if you want the text to change colors) or the background color property for the object you want to change. It would be something like this:


switch(Fields!total comparative.Value > 0, "green",
Fields!total comparative.Value -1, "yellow",
"Red")





Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
ashish.chaudhari
ashish.chaudhari
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 29
Thanks Jack.

The switch function offers to have multiple option for colors
However you can apply on the field only in whose property we have attached the code

I want to color one field depending on the value of another field

Is it possible ?
Jack Corbett
  Jack Corbett
SSCoach
SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)SSCoach (19K reputation)

Group: General Forum Members
Points: 19086 Visits: 14900
Yes you can do the same thing just substitute the field you want to use for the field that I have provided. AS long a sit is the same dataset and scope you are fine.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
ashish.chaudhari
ashish.chaudhari
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 29
Thanks
Am able to do it
ashish.chaudhari
ashish.chaudhari
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 29
I am using Function in Report properties->Code to defined the colors and passing the value to this function.

However if i had to control the colors depending on numeric values ( in decimals) the follwoing function does not allow it. Any idea?

For eg
if i want to control color if status in between -0.5 to +0.5 color = Yellow
it does not allow?

If i change the GetColor(ByVal status as string) as string from string to int or numeric it gives error,
Any idea why ?





Public Function GetColor(ByVal status as string) as string
IF status <0 Then
Return "Red"
End IF
IF status > 0 Then
Return "Green"
End IF

IF status like "0" Then
Return "Yellow"
End IF

End Function
Hari.Sharma
Hari.Sharma
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1612 Visits: 455
ashish.chaudhari (1/29/2009)
I am using Function in Report properties->Code to defined the colors and passing the value to this function.

However if i had to control the colors depending on numeric values ( in decimals) the follwoing function does not allow it. Any idea?

For eg
if i want to control color if status in between -0.5 to +0.5 color = Yellow
it does not allow?

If i change the GetColor(ByVal status as string) as string from string to int or numeric it gives error,
Any idea why ?





Public Function GetColor(ByVal status as string) as string
IF status <0 Then
Return "Red"
End IF
IF status > 0 Then
Return "Green"
End IF

IF status like "0" Then
Return "Yellow"
End IF

End Function




Ashish,

Just try to use datatype Object instead of String and Decimal.

E.g.

Public Function GetColor(ByVal status as Object) as string
IF status < 0 Then
Return "Red"
ElseIF status = 0 Then
Return "Yellow"
Else
Return "Green"
End IF
End Function

Cheers,
Hari
Tips & Tricks for SQL BI Developers

Rajesh Jonnalagadda
Rajesh Jonnalagadda
SSChasing Mays
SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)SSChasing Mays (640 reputation)

Group: General Forum Members
Points: 640 Visits: 279
Try this
Select the Textbox required
Click F4 to open properties window
In BackgroundColor click on expression
Enter
=IIF(Fields!Total.Value = 2.8, "Green", IIF(Fields!Total.Value = -1.2, "Red", IIF(Fields!Total.Value = -0.1, "Yellow", "")))

Click on Ok
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search