Search code examples
reporting-servicesssrs-2008ssrs-2008-r2

Changing background of a row for a matrix in ssrs 2008 not working properly


I have a matrix in ssrs 2008 like below:

enter image description here

What I want is to change background color of the 1st and the 4th rows. To provide this, I added the code below to the report:

Function AlternateColor(Byval rowNumber as integer) As String
Dim blue As String = "LightBlue"
Dim plum As String = "Plum"
Dim white As String = "White"

If rowNumber = 1 then 
    Return blue
Else if rowNumber = 4 then
    Return plum
Else
    Return white
End If
End Function

And I added this line as the background color expression for each cells including Fields!.Value:

=Code.AlternateColor(rownumber(nothing))

After all, this is an example from the result:

enter image description here

This is the first row, and I was expecting the see it all blue, and the 4th row all plum, the others should be all white. Changing rownumber("Tablix14") in the expression did not help as well, where matrix's name is Tablix14. Any help regarding to fix the issue here would be so appreciated. Thanks.


Solution

  • Changing the expression as below fixed the issue.

    =Code.AlternateColor(Runningvalue(Fields!FiscalQuarter.Value,CountDistinct,"Tablix14"))