SSRS Field Expression to change the background color of the Cell

前端 未结 6 2260
梦谈多话
梦谈多话 2020-12-06 00:23

I\'m trying to write a field expression for a Cell in my report where I have to change the background color of the cell depending on the string value in the cell. Ex: if the

6条回答
  •  無奈伤痛
    2020-12-06 00:40

    You can use SWITCH() function to evaluate multiple criteria to color the cell. The node is the cell fill, is font color.

    Expression:

    =SWITCH(
        (
            Fields!Usage_Date.Value.Contains("TOTAL") 
            AND (Fields!User_Name.Value.Contains("TOTAL"))
        ), "Black"
        ,(
            Fields!Usage_Date.Value.Contains("TOTAL") 
            AND NOT(Fields!User_Name.Value.Contains("TOTAL"))
        ), "#595959"
        ,(
            NOT(Fields!Usage_Date.Value.Contains("TOTAL")) 
            AND Fields!User_Name.Value.Contains("TOTAL") 
            AND Fields!OLAP_Cube.Value.Contains("TOTAL") 
        ), "#c65911"
        ,(
            NOT(Fields!Usage_Date.Value.Contains("TOTAL")) 
            AND Fields!User_Name.Value.Contains("TOTAL") 
            AND NOT(Fields!OLAP_Cube.Value.Contains("TOTAL")) 
        ), "#ed7d31"
        ,true, "#e7e6e6"
        )
    
    'Daily Totals... CellFill.&[Dark Orange]-[#c65911], TextBold.&[True]'Daily Totals... CellFill.&[Dark Orange]-[#c65911], TextBold.&[True]
    'Daily Cube Totals... CellFill.&[Medium Orange]-[#eb6e19]
    'Daily User List... CellFill.&[Light Grey]-[#e7e6e6]
    'Date Totals All Users Total... CellFill.&[Black]-["black"], TextColor.&[Light Orange]-[#ed7d31]
    'Date Totals Per User... CellFill.&[Dark Grey]-[#595959], TextColor.&[Yellow]-["yellow"]
    '(ALL OTHER CONDITIONS)
    'Daily User List... CellFill.&[Light Grey]-[#e7e6e6]
    

    XML node in report definition file (SSRS-2016 / VS-2015):

                    
                      0.2in
                      
                        
                          
                            
                              true
                              true
                              
                                
                                  
                                    
                                      =Fields!Usage_Date.Value
                                      
                                    
                                  
                                  
                                
                                =SWITCH(
        (
            Fields!Usage_Date.Value.Contains("TOTAL") 
            AND (Fields!User_Name.Value.Contains("TOTAL"))
        ), "Black"
        ,(
            Fields!Usage_Date.Value.Contains("TOTAL") 
            AND NOT(Fields!User_Name.Value.Contains("TOTAL"))
        ), "#595959"
        ,(
            NOT(Fields!Usage_Date.Value.Contains("TOTAL")) 
            AND Fields!User_Name.Value.Contains("TOTAL") 
            AND Fields!OLAP_Cube.Value.Contains("TOTAL") 
        ), "#c65911"
        ,(
            NOT(Fields!Usage_Date.Value.Contains("TOTAL")) 
            AND Fields!User_Name.Value.Contains("TOTAL") 
            AND NOT(Fields!OLAP_Cube.Value.Contains("TOTAL")) 
        ), "#ed7d31"
        ,true, "#e7e6e6"
        )
    
    'Daily Totals... CellFill.&[Dark Orange]-[#c65911], TextBold.&[True]'Daily Totals... CellFill.&[Dark Orange]-[#c65911], TextBold.&[True]
    'Daily Cube Totals... CellFill.&[Medium Orange]-[#eb6e19]
    'Daily User List... CellFill.&[Light Grey]-[#e7e6e6]
    'Date Totals All Users Total... CellFill.&[Black]-["black"], TextColor.&[Light Orange]-[#ed7d31]
    'Date Totals Per User... CellFill.&[Dark Grey]-[#595959], TextColor.&[Yellow]-["yellow"]
    '(ALL OTHER CONDITIONS)
    'Daily User List... CellFill.&[Light Grey]-[#e7e6e6]
                                2pt
                                2pt
                              
                            
                            true
                          
                        
    

提交回复
热议问题