9

I need to create alternate row colours in my RDLC report which also takes into account groups.

If I use the expression

=Iif(RowNumber(Nothing) Mod 2, "PaleGreen", "White")

Obviously this creates problems when groups are used. I've not had much luck finding information so any help would be great.

nik0lai
  • 2,585
  • 23
  • 37

3 Answers3

13

Decided to go with the following code I found online:

=IIf(RunningValue(Fields!GroupId.Value, CountDistinct, Nothing) MOD 2, "White", "#d6f1fc")

It doesnt alternate every row colour but keeps all the rows in that group the same colour which make the report nice and easy to read.

nik0lai
  • 2,585
  • 23
  • 37
7

I know this topic was brought up ages ago, but in case somebody has a similar issue (like I did) and runs into this thread, here is how I tackled it. Here is an example of the report grouping and sample results in my report:

Group 1
   Sub 1
   Sub 2
   Sub 3

Group 2
   Sub 1
   Sub 2
   Sub 3

Notice that 'Sub [1-3]' are the exact same header. When using (Fields!GroupId.Value, CountDistinct, Nothing), the statement determines that there are only 3 unique values, and when it gets to the repeating subgroups (Sub [1-3]), the result of the RunningValue does not increase.

You can test this out by putting an extra column in your report and then the expression: (RunningValue(Fields!GroupId.Value, CountDistinct, Nothing). The results would look like this:

Group 1
   Sub 1   1
   Sub 2   2
   Sub 3   3

Group 2
   Sub 1   3
   Sub 2   3
   Sub 3   3

Because the values start repeating, the 'mod 2' portion of the alternating row logic gets messed up. To work around this I had the RunningValue statement combine the Group header as well as the Sub group:

(RunningValue(Fields!GroupId.Value+Fields!SubGroupId.Value, CountDistinct, Nothing)

After I did this I got this result:

Group 1
   Sub 1   1
   Sub 2   2
   Sub 3   3

Group 2
   Sub 1   4
   Sub 2   5
   Sub 3   6

Throw that in to your alternating row expression and it should work!

Russ
  • 86
  • 1
  • 1
1

use this: =iif(RowNumber(Nothing) Mod 2 = 0, true,false)

AbhishekS
  • 71
  • 8