Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SSRS Color coding Expand / Collapse
Author
Message
Posted Wednesday, January 21, 2009 12:41 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 3:24 AM
Points: 5, 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)




Post #640467
Posted Wednesday, January 21, 2009 7:33 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Saturday, August 30, 2014 4:51 PM
Points: 11,264, Visits: 13,023
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

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
Post #640718
Posted Friday, January 23, 2009 1:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 3:24 AM
Points: 5, 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 ?

Post #642326
Posted Friday, January 23, 2009 8:04 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Saturday, August 30, 2014 4:51 PM
Points: 11,264, Visits: 13,023
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

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
Post #642479
Posted Tuesday, January 27, 2009 2:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 3:24 AM
Points: 5, Visits: 29
Thanks
Am able to do it
Post #643999
Posted Thursday, January 29, 2009 3:23 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 22, 2010 3:24 AM
Points: 5, 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
Post #645693
Posted Thursday, January 29, 2009 8:52 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, December 26, 2012 12:43 PM
Points: 1,330, 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
Post #646028
Posted Friday, January 30, 2009 11:05 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Friday, August 22, 2014 8:31 AM
Points: 610, Visits: 252
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
Post #647456
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse