1
votes

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.

1
It seems the you are passing a different rownumber for each AlternateColor function call in the same row. Note RowNumber() function could be returning different values in the same row of a matrix.alejandro zuleta
What should I use instead to fix it then:(Eray Balkanli
Maybe you can calculate in your query a column that lets you set the color in SSRS, what is the expression used for the row group?alejandro zuleta

1 Answers

1
votes

Changing the expression as below fixed the issue.

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