Alternating Row Colors in SSRS

Home > Blogs > SQL Server > Alternating Row Colors in SSRS

Alternating Row Colors in SSRS

Like This Blog 0 Peter Avila
Added by May 17, 2013

Here is a simple report with alternating row colors; in this case, PaleGoldenRod and LightSteelBlue:

Altering row colors in SQL Server SSRS

In order to create alternating colors, we start by going to the Design tab and selecting the detail row in the tablix data region.

Tablix data region altering row colors in SQL Server SSRS

Next, find the BackgroundColor property in the Properties Window (if you do not see the Properties Window, press F4). Click the BackgroundColor property’s dropdown button and select Expression…

BackgroundColor altering row colors in SQL Server SSRS

Type the following expression into the Expression Builder window (ignore the red squiggly line; it complains but it works just fine). Use whatever colors you prefer.

Expression Builder window altering row colors in SQL Server SSRS

Here’s how that expression works: RowNumber() is a function that returns the current row number when the report runs. Inside the parenthesis, we specify the scope, or when we want the row number to reset to 1. By using “Nothing,” we tell it that the scope is the entire report, so that row numbers start with 1 on the first row and just keep counting up through the entire report (if we had wanted to reset row numbers at the start of every group, for example, we would have put the name of the group in the parenthesis, delimited in double quotes). The Mod operator stands for “modulo,” which returns the remainder of a division. In this case, the expression returns the remainder of a division in which the row number is divided by two. If the remainder is 1, then the row number is odd, and if it is two, the row number is even. In VB.Net, which is the language used in the Expression dialog, 0 is False and any other number is equivalent to True. So, when the row number is odd, the remainder is 1, or True, which causes the PaleGoldenRod color to be returned. When the row number is even, the remainder is 0, or False, which causes the LightSteelBlue color to be returned.

Once you’ve entered the expression, click OK, preview your report, and enjoy the alternating colors!

Peter Avila
SQL Server Instructor – Interface Technical Training
Phoenix, AZ

Videos You May Like

A Simple Introduction to Cisco CML2

0 3955 0

Mark Jacob, Cisco Instructor, presents an introduction to Cisco Modeling Labs 2.0 or CML2.0, an upgrade to Cisco’s VIRL Personal Edition. Mark demonstrates Terminal Emulator access to console, as well as console access from within the CML2.0 product. Hello, I’m Mark Jacob, a Cisco Instructor and Network Instructor at Interface Technical Training. I’ve been using … Continue reading A Simple Introduction to Cisco CML2

Creating Dynamic DNS in Network Environments

0 649 1

This content is from our CompTIA Network + Video Certification Training Course. Start training today! In this video, CompTIA Network + instructor Rick Trader teaches how to create Dynamic DNS zones in Network Environments. Video Transcription: Now that we’ve installed DNS, we’ve created our DNS zones, the next step is now, how do we produce those … Continue reading Creating Dynamic DNS in Network Environments

Cable Testers and How to Use them in Network Environments

0 753 1

This content is from our CompTIA Network + Video Certification Training Course. Start training today! In this video, CompTIA Network + instructor Rick Trader demonstrates how to use cable testers in network environments. Let’s look at some tools that we can use to test our different cables in our environment. Cable Testers Properly Wired Connectivity … Continue reading Cable Testers and How to Use them in Network Environments

Write a Comment

Share your thoughts...

Please fill out the comment form below to post a reply.