How to create Alternative Row Background colors in SSRS for values in a group

前端 未结 1 1232
庸人自扰
庸人自扰 2020-12-18 16:47

I am using this expression to get alternative colors for my row group:

=iif(RunningValue(Fields!Status_Reason.Value,CountDistinct,Nothing) Mod 2, \"LightBlue         


        
相关标签:
1条回答
  • 2020-12-18 17:02

    I use some VB code for Alternating the row color. It's a little more work to set up at first, but it always works right and you can re-use the code in other reports by copying the VB code.

    Expression:

    =code.AlternateColor("AliceBlue", "White", 1, 1)
    
    =code.AlternateColor("AliceBlue", "White", 0, 1)
    

    The first column should have the first expression - the first 1 in the argument tells it to change color. The remaining columns use the second expression with the 0 indicating that the color won't change.

    VB CODE:

    Private bOddRow(10) As Boolean 
    
    Function AlternateColor(ByVal OddColor As String, ByVal EvenColor As String, ByVal Toggle As Boolean, ByVal Type AS INTEGER) As String 
    
      If Toggle Then bOddRow(Type) = Not bOddRow(Type) 
    
      If bOddRow(Type) Then 
                    Return OddColor 
      Else 
                    Return EvenColor 
      End If 
    
    End Function
    

    If you have multiple levels of grouping in one table, you would change the second number of the expression so the rows are unique for each group. In the below example, the main grouping is colored in white and AliceBlue and the sub group is whitesmoke and a lighter blue.

    0 讨论(0)
提交回复
热议问题