Home > Reporting Services > Alternating row colours in the Tablix cotrol

Alternating row colours in the Tablix cotrol

In Reporting Services 2000 and 2005 , we used a nifty trick to get alternating background colours per row within a table control. Yes, I’ve spelt colour with a "u", and yes, I’ve used "spelt" and not "spelled", for our friends across the Atlantic. But getting back to Reporting Services , here is the old code :

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

This never worked properly for the Matrix control, however. The big question now, though, is – Will this work with the Tablix control ? Well , I’ll put you out of your agony – it doesn’t. Which means we need a new piece of code. This is what I’ve found :


=iif(RunningValue(Fields!Region.Value,CountDistinct,Nothing) MOD 2,"Gainsboro","White")

You have to reference a column in your tablix for the running value, so it’s not proper "cut and paste" code, but it has worked for me in reports that I’ve tried so far. Give it a go and let me know …….

UPDATED 16/01/2009 :

Ok, I’ve actually found that the above doesn’t work that well when you have a tablix that’s started out as a table. That’s fine though , you simply revert back to the old code ( the one at the top ) and you’ll get your alternating row colours.

Categories: Reporting Services
  1. enguerran
    December 14, 2012 at 12:55 pm

    It’s not working when you’ve got an empty value for a group

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: