Based on this answer to another question I have another method for alternating the row colours, this time taking the hidden row into consideration.
You need to add the following Custom Code to the report
Dim CurrentColour As String
Dim LastRowNumber AS Integer
Function SwitchColour(ThisRowNumber As Integer) As String
If CurrentColour = "" Then
CurrentColour = "Red"
End If
If LastRowNumber = 0 Then
LastRowNumber = ThisRowNumber
End If
If LastRowNumber <> ThisRowNumber Then
' Change the colour
If CurrentColour = "Red" Then
CurrentColour = "Yellow"
Else
CurrentColour = "Red"
End If
LastRowNumber = ThisRowNumber
End If
Return CurrentColour
End Function
This is effectively saving a value for the CurrentColour to persist across the elements in the report. When the SwitchColour function is run it determines if the row number has changed (LastRowNumber <> ThisRowNumber
), and if so changes the colour for the cells.
Using this sample data as “DataSet1”
Val | Colour
----+-------
36 | Red
22 | Red
55 | Green
23 | Red
74 | Red
And setting the cells BackgroundColour
to
=Code.SwitchColour(RowNumber(“DataSet1”))
Give this result
When you then apply a visibility expression to the Row to negate the value “Green” for example using this expression
=iif(Fields!Colour.Value = "Green", True, False)
The result is like this
Note the colouring still changes, despite there being a record absent from the middle of the table
Is this the sort of behaviour you would like, and is it something you can apply to your project? If you need further assistance, please let me know.