all groups > sql server reporting services > august 2006 >
You're in the

sql server reporting services

group:

Alternate row colors by group


Alternate row colors by group BillTWD
8/16/2006 1:46:02 PM
sql server reporting services:
I have a report in which the results are grouped. For example, the report
returnd 25 rows, the first 5 rows are one group (lets say all 'A's, the
second 5 rows are another group (lets say all 'B's), etc...

Can I add conditional formatting to alternate the backgroup color based on
groups?

I know I can alternate row colors using:

=iif(RowNumber(Nothing) Mod 2, "WhiteSmoke", "White")

But I want to alternate by group. Is that possible and if so, how?

RE: Alternate row colors by group Jim
8/17/2006 5:46:01 PM
I had a similar requirement recently but could find nothing in help or on the
net. I wrote this embedded code which works for me but I'm curious if there's
a simpler way.

Add this to the report's embedded code window:

Public GroupRowCounter As Integer = 0

Function IncrementCounter() As Integer
GroupRowCounter += 1
Return GroupRowCounter
End Function

Function GetCounter() As Integer
Return GroupRowCounter
End Function


Right click the header row you want the alternate coloring in and select
Insert Row Above. In the new, topmost header row set the Hidden property to
True and add this to one of the cells:
=Code.IncrementCounter

For the header/detail/footer portions of the group that will be visible, add
this to the BackgroundColor property to alternate the row (group) colors:
=IIF(Code.GetCounter Mod 2, "WhiteSmoke", "White")


[quoted text, click to view]
RE: Alternate row colors by group Mike
10/2/2006 11:44:01 PM
If you're grouping on Country, this is the code to use.

=Iif(RunningValue(Fields!Country.Value,CountDistinct, Nothing) Mod 2,
"LightGreen", "Cornsilk")

Mike Glaser

[quoted text, click to view]
AddThis Social Bookmark Button