Articles in this section
Category / Section

How to Apply Alternating Row Colors in a Tablix

Published:
Updated:

Applying alternating row colors in a tablix is a technique used to enhance the readability and visual appeal of a report. By assigning different background colors to consecutive rows, you can create a visual pattern that helps users distinguish between rows more easily. Here’s how to apply alternating row colors in a tablix:

  1. Create a report with a tablix and configure the Tablix control by defining the dataset and adding the necessary columns and rows. You can bind the Tablix to a data source by specifying the dataset name, table or view name, and any required parameters.

    Tablix.png

  2. Select the tablix control to which you want to apply alternating row colors. Then, select the entire row group.

    RowGroup.png

  3. In the properties window or pane, under the Appearance category, click on the square icon located at the right corner of the Background Color property. Then, click on the Expression menu to open the expression builder.

    Expression.png

  4. In the expression editor, enter the following expression to define the alternating row colors:

    =IIF(RowNumber(Nothing) MOD 2 = 1, "#F2F2F2", "#FFFFFF")
    

    BackgroundColor.png

Note: This expression uses the RowNumber function to get the current row number, and the Mod operator to determine if the row number is even or odd. If it’s even (divisible by 2), the first color (#F2F2F2) is applied, and if it’s odd, the second color (#FFFFFF) is applied.

  1. Preview the report to see the alternating row colors in action. The rows should now have different background colors, alternating based on the expression and row number.
    Output.png
Report.rdl
Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied