none
Background color change in SSRS

    Question

  • Im trying to Highlight the row for 'Major group' and its 'subgroup' row in my report. where I have to change the background color of the row depending on the string value in the cell. Eg: if the column has a value 'MG' in it, the cell should show a 'SomeColor, say Green' background color. I tried the following:

    =IIF(Fields!ProductGroup.Value = "MG", "Green", "No Color")
    =Switch(Fields!ProductGroup.Value = "MG", "DarkViolet", Fields!ProductGroup.Value="SG","Gold")
    Nothing is working for me. Am i missing anything ? Please help!

    (NB : I have 1 row_group. which displays the select query data)

    Tuesday, October 11, 2011 8:16 AM

Answers

  • It is also possible that there are trailing spaces on the field. Try

     

    =IIF(TRIM(Fields!ProductGroup.Value) = "MG", "Green", "No Color")

    OR

    =IIF(LEFT(Fields!ProductGroup.Value,2) = "MG", "Green", "No Color")

    • Marked as answer by sunumon Wednesday, October 12, 2011 12:43 PM
    Wednesday, October 12, 2011 12:19 PM

All replies

  • Hi,

    Are you writing this expression in background color property.

    select the row and press F4 you can find the Background color in properties Window,select expression and write this expression

    =Switch(Fields!ProductGroup.Value = "MG", "DarkViolet", Fields!ProductGroup.Value="SG","Gold")


    Mark this as answer if this post helps you.
    Tuesday, October 11, 2011 9:35 AM
  • Hi Ramya,

    Thanks for your reply.

    Yes im writing the expression in background color property. 

    I also tried with IIF, but both are not working.

        -Sunoj

     

     

     

     

    Tuesday, October 11, 2011 9:49 AM
  • Hi Sunumon

    Try Below Expression

    = IIF(RowNumber(Nothing) Mod 2, "Group Name", "Green")

    = IIF(RunningValue(Fields!Some_Field.Value, CountDistinct, "Group Name") Mod 2, "Gold", "Green")

    =IIF(RunningValue(Fields!Some_Field.Value, Count, "Group Name") Mod 2, "Gold", "Green")

    =IIf(RunningValue(1, Sum, "Group Name") Mod 2, "Gold", "Green")


    SUHAS http://suhaskudekar.blogspot.com/ Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.
    Tuesday, October 11, 2011 10:06 AM
  • Hi Suhas,

    Thanks for your reply.

    I tried all the expression you gave. here are the results

    1.) alternate color by line

    2, 3, 4.) all rows are 'Gold' background

    These are not wat im expecting.

    Actually i want only 'Major Group' as colored background and sub group as 'non-color' or any color(optional).

    Main idea is to differentiate the 'major Group' and 'sub-Group'.

     

    -Sunoj


    • Edited by sunumon Tuesday, October 11, 2011 12:52 PM
    Tuesday, October 11, 2011 10:21 AM
  • Any help on this please...

     

    Wednesday, October 12, 2011 8:16 AM
  • Hi sunnumou,

    Thanks for your post.

    Instead of clicking the row handle to specify the backgroundcolor expression, I would suggest you to press Ctrl and click each cell of the row, then release Ctrl key and press F4 , scroll to the backgroudcolor property, specify the expression to =IIF(Fields!ProductGroup.Value = "MG", "Green", "No Color").At last, run your report to verify whether it works as you expected.

    Thanks,
    Bill Lu


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, October 12, 2011 8:26 AM
    Moderator
  • Hi Bill,

    Thanks for your reply.

    I tired as you suggested but in vein.

    Im going mad donno what more i can do to get it working.

        -Sunoj

    Wednesday, October 12, 2011 9:45 AM
  • Hi Sunumon,

    Can you kindly upload the Required output by replicating it in an excel file for better understanding of the team ?


    Rakesh M J

    Dont forget to mark it as Answered if found useful

    MCTS,MCITP,MCSS

    http://myspeakonbi.blogspot.com/

    Wednesday, October 12, 2011 10:30 AM
  • Hi Rakesh,

    Thanks for reply.

    Below is the scrren shot of how my report look like.

    The Major group row should be highlighted and sub group not.

    There is column in the select query called 'Product Group' which says the data is major group or sub group ('MG' or 'SG')

    Revert for more details.

     

    Thanks.

     -Sunoj

     

     


    • Edited by sunumon Wednesday, October 12, 2011 11:00 AM
    • Proposed as answer by JLHui Wednesday, October 12, 2011 11:20 AM
    • Unproposed as answer by JLHui Wednesday, October 12, 2011 11:20 AM
    Wednesday, October 12, 2011 10:42 AM
  • I suspect that the field is not returning as you expected. Try to show the values of Fields!ProductGroup.Value on one of the columns to check.
    Wednesday, October 12, 2011 11:22 AM
  • Hi Jlhui,

    Thanks for your reply.

    I have added the Product Group column for reference.

    I can see the column is non-empty or null. Can you think of anyother options ?

    Thanks,

        -Sunoj

    Wednesday, October 12, 2011 11:38 AM
  • It is also possible that there are trailing spaces on the field. Try

     

    =IIF(TRIM(Fields!ProductGroup.Value) = "MG", "Green", "No Color")

    OR

    =IIF(LEFT(Fields!ProductGroup.Value,2) = "MG", "Green", "No Color")

    • Marked as answer by sunumon Wednesday, October 12, 2011 12:43 PM
    Wednesday, October 12, 2011 12:19 PM
  • Hi,

    Sometimes BIDS do not behave Normally. If you Can Re-Create the Tablix of the Report Again and Add

    IIF(Fields!ProductGroup.Value = "MG", "Green", "No Color")
    to Row Background Properties by pressing F4.But do not Copy and create the Report from Scratch might Work.

    Rakesh M J

    Dont forget to mark it as Answered if found useful

    MCTS,MCITP,MCSS

    http://myspeakonbi.blogspot.com/

    Wednesday, October 12, 2011 12:20 PM
  • Hi Rakesh,

     

    It worked as with Jlhui suggestion.

     

    Thanks,

      -Sunoj

    Wednesday, October 12, 2011 12:49 PM
  • Hi Jlhui,

     

    Thanks a ton. Atlast it worked :)

    Thanks Again.

       -Sunoj

    Wednesday, October 12, 2011 12:50 PM