locked
Is there a way to conditionally format background color for ALL columns, rather than one column at a time? RRS feed

  • Question

  • User846546683 posted

    I know how to conditionally format a cell value based on a column name:

    =iif(Fields!Form.Value="Unk","Red","White")

    Rather than have to do an expression one at a time for each column, is there a way I can define this for cells in the entire table?

    Thanks

    Friday, May 1, 2015 1:02 PM

Answers

  • User1711366110 posted

    Rather than have to do an expression one at a time for each column, is there a way I can define this for cells in the entire table?

       As per this case, I have shared my ideas below :
    1. As far as I know, we can set the conditional based expression on single column rather than multiple column at a time

    2.If you have multiple condition against single field or column, you can use SWITCH instead of IIF like below :

    =switch(Fields!Form.Value="Unk","Red",
    Fields!Form.Value="mnk","white",
    ...
    Fields!Form.Value="pnk","yellow")

    3.you can create custom function & reuse to all fields/columns in a table. But you need to set it as individually.
    Custom function :
    Navigate to Design tab-->Report menu-->Properties-->code tab

    Public Function GetBackgroundColor(ByVal status as String) as String 
       IF status = "Unk" Then 
          Return “Red" 
    ELSE
    Return “White" End IF End Function

    Then call this custom function to all fields individually as well as manually like below :

    =code.GetColor(Fields!Field1.Value)

    =code.GetColor(Fields!Field2.Value)

    =code.GetColor(Fields!Field3.Value)

    --
    with regards,
    Edwin

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 3, 2015 11:11 PM

All replies

  • User1711366110 posted

    Rather than have to do an expression one at a time for each column, is there a way I can define this for cells in the entire table?

       As per this case, I have shared my ideas below :
    1. As far as I know, we can set the conditional based expression on single column rather than multiple column at a time

    2.If you have multiple condition against single field or column, you can use SWITCH instead of IIF like below :

    =switch(Fields!Form.Value="Unk","Red",
    Fields!Form.Value="mnk","white",
    ...
    Fields!Form.Value="pnk","yellow")

    3.you can create custom function & reuse to all fields/columns in a table. But you need to set it as individually.
    Custom function :
    Navigate to Design tab-->Report menu-->Properties-->code tab

    Public Function GetBackgroundColor(ByVal status as String) as String 
       IF status = "Unk" Then 
          Return “Red" 
    ELSE
    Return “White" End IF End Function

    Then call this custom function to all fields individually as well as manually like below :

    =code.GetColor(Fields!Field1.Value)

    =code.GetColor(Fields!Field2.Value)

    =code.GetColor(Fields!Field3.Value)

    --
    with regards,
    Edwin

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 3, 2015 11:11 PM
  • User846546683 posted

    Thanks. You've confirmed what I was afraid of: it's one column at a time...

    Sunday, May 3, 2015 11:18 PM