locked
Alternate Fill color in tablix detail section based on data values RRS feed

  • Question

  • I have a tablix control and am trying to alternate the background color of the detail section based on data values.

    I am sorting by MC_CustomerName.

    Every time the MC_CustomerName changes I want to change the background color

    In the fill property I have this expression:

    = IIf(Fields!MC_CustomerName.Value=Previous(Fields!MC_CustomerName.Value)

    I am using the same logic to hide the duplicate data value(s) and that is working fine

    Friday, January 4, 2013 9:46 PM

Answers

  • Hi James,

    Sorry for my misunderstanding in my reply. Based on your desciption, the background color of rows is "White" and "Gray" alternately based on the field "MC_CustomerName" value.
    In order to meet your requirement, Please refer to the following steps:
     1. Add a row group into the Tablix and group the report data by the field "MC_CustomerName".

     2. Specify the background color for the detail section with following expression:
    =IIF((Runningvalue(fields!MC_CustomerName.Value,countdistinct,"DataSet2") mod 2)=1,"White","Grey")

    If you have any question, please let me know.

    Regards,

    Fanny Liu


    Fanny Liu
    TechNet Community Support

    • Proposed as answer by Fanny Liu Thursday, January 10, 2013 5:40 AM
    • Marked as answer by Fanny Liu Monday, January 14, 2013 1:19 AM
    Tuesday, January 8, 2013 3:40 AM
  • James,

    Try this:

    http://blogs.msdn.com/b/chrishays/archive/2004/08/30/greenbarmatrix.aspx

    http://www.bidn.com/blogs/briankmcdonald/bidn-blog/717/alternating-group-colors-and-alternating-row-colors

    The other work around even I have tried a lot of ways, only way I could resolve this:

    create an empty row group with an expression and hide that:

    =iif(RunningValue(Fields!FieldName.Value,CountDistinct,Nothing) Mod 2, "#eaeaea" , "White")

    Use the same expression for the actual group and dummy group background color property.

    for measures (or values columns) use "=ReportItems!RowColorGroupTextbox1.Value" (the cell name that is created earlier) as a background expression.

    Hope it is helpful!

    Regards,Eshwar.

    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.



    • Edited by Eswararao C Tuesday, January 8, 2013 6:17 AM
    • Proposed as answer by Fanny Liu Thursday, January 10, 2013 5:43 AM
    • Marked as answer by Fanny Liu Monday, January 14, 2013 1:19 AM
    Tuesday, January 8, 2013 6:07 AM

All replies

  • Try this:

    http://thavash.wordpress.com/2008/09/18/alternating-row-colours-in-the-tablix-cotrol/

    Regards,Eshwar.


    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.

    Monday, January 7, 2013 7:12 AM
  • Hi James,

    Based on your description, you want to change the background color only when the value of the filed "MC_CustomerName" changed. When using the expression your post, the color of  first row will change anyhow. To solve this issue, we can use nested IIF function, please refer to the following expression:

    = IIf(Fields!MC_CustomerName.Value=First(Fields!MC_CustomerName.Value,"DataSetname"),"Pink",IIF(Fields!MC_CustomerName.Value=Previous(Fields!MC_CustomerName.Value),"Pink","Gold"))

    = IIf(Fields!MC_CustomerName.Value=First(Fields!MC_CustomerName.Value,"DataSetname"),"Pink",IIF(Fields!MC_CustomerName.Value=Previous(Fields!MC_CustomerName.Value),"Pink","Gold"))

    Regards,

    Fanny Liu


    Fanny Liu
    TechNet Community Support


    • Edited by Fanny Liu Monday, January 7, 2013 9:37 AM
    Monday, January 7, 2013 9:36 AM
  • This didnt quite work. It changed the 1st time the data changed, but it never changed back. Every time the data changes it is suppose to alternate between white and gray. this started out white, then changed to gray the 1st time, but continued to stay gray for all of the subsequent changes.

    isnt there a way to compare the current value to the previous value and then get the previous values backgroundcolor?

    i.e.

    if current field value = previous field value then previous field background color, else if previous field background color = white then gray, else white

    or is background color only read only?

    thanks

    Monday, January 7, 2013 2:35 PM
  • this doesn't work. his has to change color every time the data changes, not every time the row changes.

    it needs to start out white and then when the data changes it needs to change to gray, then when the data changes again back to white

    Monday, January 7, 2013 2:39 PM
  • Hi James,

    Sorry for my misunderstanding in my reply. Based on your desciption, the background color of rows is "White" and "Gray" alternately based on the field "MC_CustomerName" value.
    In order to meet your requirement, Please refer to the following steps:
     1. Add a row group into the Tablix and group the report data by the field "MC_CustomerName".

     2. Specify the background color for the detail section with following expression:
    =IIF((Runningvalue(fields!MC_CustomerName.Value,countdistinct,"DataSet2") mod 2)=1,"White","Grey")

    If you have any question, please let me know.

    Regards,

    Fanny Liu


    Fanny Liu
    TechNet Community Support

    • Proposed as answer by Fanny Liu Thursday, January 10, 2013 5:40 AM
    • Marked as answer by Fanny Liu Monday, January 14, 2013 1:19 AM
    Tuesday, January 8, 2013 3:40 AM
  • Hi James,

     

    Please refer to the below link with different options to represent alternate colors.

    http://social.technet.microsoft.com/Forums/en-US/sqlreportingservices/thread/69ce64e8-9b14-4e64-9882-b8a5141fcfa8

     

    Hope it'll help in resolving your issue,thank you...


    - Arun Gangumalla, Please mark as helpful or answered if it resolves your issue to help others in finding solutions easily.

    Tuesday, January 8, 2013 5:55 AM
  • James,

    Try this:

    http://blogs.msdn.com/b/chrishays/archive/2004/08/30/greenbarmatrix.aspx

    http://www.bidn.com/blogs/briankmcdonald/bidn-blog/717/alternating-group-colors-and-alternating-row-colors

    The other work around even I have tried a lot of ways, only way I could resolve this:

    create an empty row group with an expression and hide that:

    =iif(RunningValue(Fields!FieldName.Value,CountDistinct,Nothing) Mod 2, "#eaeaea" , "White")

    Use the same expression for the actual group and dummy group background color property.

    for measures (or values columns) use "=ReportItems!RowColorGroupTextbox1.Value" (the cell name that is created earlier) as a background expression.

    Hope it is helpful!

    Regards,Eshwar.

    Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.



    • Edited by Eswararao C Tuesday, January 8, 2013 6:17 AM
    • Proposed as answer by Fanny Liu Thursday, January 10, 2013 5:43 AM
    • Marked as answer by Fanny Liu Monday, January 14, 2013 1:19 AM
    Tuesday, January 8, 2013 6:07 AM