none
SSRS 2008 Conditional formatting of chart labels

    Question

  • Hi everyone,

    is it possible for the labels of a chart axis to add conditional coloring. I tried to changed it according to its value but it does not get applied. I need to have labels with positive values in black and with negative red.

    Any ideas will be very much appreciated

    Tuesday, May 26, 2009 8:17 AM

Answers

  • Good lively thread here.  This is actually not a bug in terms of how the chart currently works, but is by design.  It's a bit misleading due to the fact that the property page supports expression based formatting for the axis labels which it shouldn't. 

    Going forward, this is definitely a feature we would like to enable.  Thank you for posting the feedback.  The issue is definitely on our radar.

    -Sean

    Program Manager, SQL Server Reporting Services This posting is provided "AS IS" with no warranties, and confers no rights. http://blogs.msdn.com/seanboon http://www.twitter.com/ssrs
    Tuesday, June 02, 2009 5:40 PM

All replies

  • yes, i think we can do this..
    under the Axis properties, there is an option called 'Label Font'. If you click on it you will be able to see the 'color' option.Besides this, there is a button for expression. Here i think you can set the color based on the condition.

    This is with repect to SSRS 2008,Hope this is helpful.

    Best Regards,
    Azhar

    Tuesday, May 26, 2009 2:16 PM
  • Hi Marie,


    Try this: 

    1)    Select the chart, right click the chart, and click properties.

    2)    In Chart Properties window, switch to data tab. select the value group, click edit button.

    3)    In edit chart value window, switch to data tab. switch to point labels tab. click label style button.

    4)    In style properties window, set the color with expression:

    =iif(Fields!amount.Value<0,"red","black")

     

    Hope this helps.

    Raymond

    Wednesday, May 27, 2009 7:10 AM
  • Hi,

    I did exactly this I added IIf condition for the value axis properties labels font colors but it does not get applies: something like:=iif(Fields!ValueField.Value = "Some string", "Black", "Red") but I get all labels in red...
    Any ideas?

    Thank you,

    Maria
    Wednesday, May 27, 2009 10:09 PM
  • Hi Marie,

     

    I believe iif expression works all right. The issue is caused by your data. You can test expression with :

    =iif(true,"red","black")

    =iif(false,"red","black")

    You will find the color always base on your condition expression: Fields!ValueField.Value = "Some string"

     

    I mean, the expression always return false, the field Fields!ValueField.Value never return “Some string”

    So I think you can check the Fields!ValueField.Value, whether the string include spaces, or the wrong data format. Make sure you catch the correct string.

     

    Hope this helps.

    Raymond

    Friday, May 29, 2009 1:56 AM
  • Hi Raymond,

    Thanks for the help. The evaluation expression within the iif statement works. However, in my case what happens is.
    I added the conditional coloring:

    =iif(Fields!Value.Value = 1,

    "red", "black") and I have values of 1,2,3,4 . I get all axis labels in red. If the expression is =iif(Fields!Value.Value = 2, "red", "black") I get all values in black. I.e. this coloring is applied to all the members in the collection. What I need to achieve in the first case is the following:

    condition: =iif(Fields!Value.Value = 1, "red", "black")
    result: 1 (colored red), 2 (colored black), 3 (colored black), 4 (colored black)

    for the second case

    condition: =iif(Fields!Value.Value = 2, "red", "black")
    result: 1 (colored black), 2 (colored red), 3 (colored black), 4 (colored black)

    It is really something very simple and I can not figure out what the problem is - is it not supported formatting of specific members within the labels collection or am I doing something really wrong :)

    Once again thank you for the help.

    Maria

    Tuesday, June 02, 2009 10:31 AM
  • Hi Marie,

     

    It’ really strange a issue, because the conditional color always works in my situation - I tested it in Server pack 1 and server pack 3. Suppose the x-axis is group by Fields!columnx.Value, could you using following expression for label color:

    =iif(Fields!columnx.Value<0,"red","black")

    And suppose the y-axis is group by Fields!columny.Value, could you using following expression for label color:

    =iif(sum(Fields!columny.Value)<10,"red","black")

     

    And if you still cannot get the correct result, to validate if this is a bug, I think you could connect to

    https://connect.microsoft.com/SQLServer/

     

    Hope this helps.

    Raymond

     

    Tuesday, June 02, 2009 11:03 AM
  • Thank you Raymond,

    I posted a feedback here:
    https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=463179

    Hope the issue will have a resolvement.

    Kind regards,

    Maria
    Tuesday, June 02, 2009 12:58 PM
  • Good lively thread here.  This is actually not a bug in terms of how the chart currently works, but is by design.  It's a bit misleading due to the fact that the property page supports expression based formatting for the axis labels which it shouldn't. 

    Going forward, this is definitely a feature we would like to enable.  Thank you for posting the feedback.  The issue is definitely on our radar.

    -Sean

    Program Manager, SQL Server Reporting Services This posting is provided "AS IS" with no warranties, and confers no rights. http://blogs.msdn.com/seanboon http://www.twitter.com/ssrs
    Tuesday, June 02, 2009 5:40 PM
  • ?

    Are you saying that there's a dialog box for creating an expression to set the color property of labels, and it doesn't actually do anything?

    I hope not.
    Wednesday, September 09, 2009 3:15 PM
  • ?

    Are you saying that there's a dialog box for creating an expression to set the color property of labels, and it doesn't actually do anything?

    I hope not.

    Unfortunately he is...  As far as I can tell, the expression does actually do something but it will use the first record in the dataset to calculate the result for the whole chart, not really what you'd want to achieve.

    MCITP SQL Server 2008 (DEV); MCTS SQL Server 2008 (BI, DEV & DBA)

    Monday, July 30, 2012 9:38 AM