Updated April 3, 2023
Introduction to SSRS Alternate Row Color
Enabling alternate row colors in SQL Server Reporting Services (SSRS) is a key visualization setup for end-users to quickly examine their views and gain greater reading accessibility for users and an aesthetically beautiful report. To retrieve the row’s position, use the Row Number() method, adjust the background color, or use the Running Value() function. The running total is the sum of all non-zero integer numbers. For example, utilize the Running Value procedure to construct a Total Running Column in SSRS.
Overview of SSRS Alternate Row Color
To check for alternate rows, we’ll need to utilize a condition. Because of this, we’ll be taken to the Data Source Properties dialogue box. Next, enter your data source’s name in the Name field of the Data Source Settings dialogue box’s Navigation pane, and choose “Microsoft Azure SQL Database” as the connection type from the drop-down option. Then, on the right-hand side, click the Build button.
- Enter Localhost as your Server name on the “Connection Properties” page.
- Choosing information for your report.
- To use it as a dataset query, open the Query Designer, change the Edit as Text setting to Text, and then type the expression. A dataset could be taken of our choice.
Steps to be followed
To change the tone of the alternate row, do the preceding:
- First, pick the Home tab, the Text Formatting group, and the Alternate Row Color drop-down arrow in the Text Formatting group.
- Pick the Home tab, the Text Formatting group, and the Alternate Row Color drop-down arrow in the Text Formatting group.
- Choose a color from the drop-down option, or eliminate the additional row color by selecting No Color.
- The color of the alternate row will be changed.
Let’s see the process in detail:
Following is the initial process to go with:
A new expression window will open after users click the Expression link. Look for alternate rows using this expression pane. We can use any colors we like. For example, to modify the background color, rather than picking each column value a little at a time, we might choose the entire row, updating them all at once. Scroll down and fill the Properties window once the full row has been selected.
This is where BackgroundColor is found. We need a different phrase for the BackgroundColor attribute than the standard:
=iif(rownumber (nothing) mod 2 = 0, "PaleGoldenRed", "White")
We will use the SSRS functions Row Number and Modulo for alternate row coloring. Here, the row Number function returns the count of rows within the provided region as a continuous value. So, every row has a count inside one defined range. The scope can be shown in Row/Column Groups.
Modulo: Returns the residual of one number divided by another using the modulo function.
dividend % divisor (syntax)
The following is how that expression works:
When the report executes, the Row Number() function will return the actual row number. The scope, or whenever we want the row number to change to 1, is specified inside the brackets. We inform it that the scope is the full report using “Nothing,” so row numbers begin with one on the first row and continue counting up through the entire document. The Mod operator returns the residue of a division and stands for “modulo.” The residue of a division where the row number is split by two is returned in this example by the phrase.
The row number is odd if the remainder is one, even if the remaining is two. In VB.Net, the language used in the Expressions dialogue, 0 represents False, or any integer represents True. Therefore, when the row value is odd, the remainder is 1, or True, restoring the PaleGoldenRod color. When the row value is even, the remainder is 0, or False, resulting in the return of the LightSteelBlue color. Here is our sample report:
Alternate rows of the table are highlighted in a specified color in the output.
Example of SSRS Alternate Row Color
Let’s see how to implement alternate background colors in rows here. Let’s get started:
Step 1: The first step is to choose a corresponding data source and a query format. Click Data Set Properties and navigate through the steps.
Step 2: In the Dataset given, we have used the following Custom SQL query:
We saw that we initially had a report name, and the background color was None or white.
Step 3: Meanwhile, insert a Table here:
Then, in the SSRS report, build a table and connect it to the data set; we will get the following report.
Then, right-click on the data field, insert all the necessary fields and click preview to view a table.
Select BackgroundColor Property in the Properties box, then select the arrowhead button on the side. Then, as indicated in the screenshot below, click on expression. When we click on the BackgroundColor option, a color window appears, and we can see that the background color is configured to No Color, which implies the backdrop seems to have no color.
If needed the same color for all rows, one can choose any color from the color window; however, we would like to give the report an alternate row color, so click on the Expression box.
The Expression is given as
=IIF(ROWNUMBER(NOTHING) MOD 2, "LIGHTGREY", "WHITE")
This expression specifies a different row background color; we can use any color we choose. Colors could also be represented using hexadecimal values. Color hexadecimal values can be found here. Then press the OK button. Take a look at the image below.
Step 6: Now that we’ve done all the required reforms, let’s look at the report. Each Tablix row does have a distinct backdrop color, as shown in the image below. The final report should look like this:
Alternate Row Colors in SSRS Matrix Control: Matrix is a SQL Server Reporting Services function that allows users to create variable columns and rows. This implies that, unlike the last table example, columns will increase in the matrix control.
Finally, this article shows how to add Alternative Row Color to an SSRS Report. Also completed with an example of how to add Alternative Row Colors to an SSRS Report using Expressions. This notion makes the report more accessible for business customers and simplifies.
We hope that this EDUCBA information on “SSRS Alternate Row Color” was beneficial to you. You can view EDUCBA’s recommended articles for more information.