Articles in this section
Category / Section

How to Apply Alternating Row Colors in a Matrix Grouping?

Published:
Updated:

Applying alternating row colors in a Matrix is a valuable technique that enhances the readability and visual appeal of reports. By assigning different background colors to consecutive rows, you can create a visual pattern that makes it easier for users to distinguish between rows. Follow this step-by-step guide to apply alternating row colors in a matrix grouping:

  1. Start by creating a report and adding a matrix control. Configure the matrix by specifying the dataset and adding the necessary columns and rows.

    image.png

  2. Next, introduce a variable in the report item, which will control the background color changes.

    image.png

  3. In the Variable properties, provide the variable name and set the initial value to ensure it functions correctly.

    image.png

  4. Select the Grouping cell in the matrix where you want to apply alternating row colors,and add the visibility expression.

    image.png

  5. Insert the following expression for the visibility of the grouping cell:

    image.png

    =!IIF(RunningValue(Fields!SubCat.Value, CountDistinct, "ProductCategory") Mod 2 = 1, Variables!RowId.SetValue(1), Variables!RowId.SetValue(0))
    

    RunningValue(Fields!SubCat.Value, CountDistinct, “ProductCategory”): This expression retrieves the current row value for the group.
    Variables!RowId.SetValue(1): This expression sets the value of the variable to 1.
    Variables!RowId.SetValue(0): This expression sets the value of the variable to 0.

  6. Select the cell within the matrix where you want to alternate the row color.

    image.png

  7. Include the following expression in the background color property:

    image.png

    =IIf(Variables!RowId.Value = 1, "White", "Green")
    
  8. Repeat the process for other cells where you want to apply alternating row colors.

    image.png

  9. Save the changes and run the report.

    image.png

By following these steps, you can successfully apply alternating row colors in a matrix grouping to improve the readability of your report.

You can download the sample report from here.

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied