Showing posts with label reporting services. Show all posts
Showing posts with label reporting services. Show all posts

Monday, December 29, 2008

matrix RowNumber doesn't work with even rows

I recently ran into a new issue with Microsoft Reporting Services 2005 matrix control.
When trying to color alternating columns with collapsible row groups, I discovered that when a group contained an even number of rows the typical alternating code didn't work:
iif(RowNumber("matrix_RowGroup") Mod 2, "LightGrey", "White")

This is due to RowNumber being multiplied by the number of rows when a group is collapsed.

After some research and playing around I discovered that CountRows() would give me the number of rows in the current context, so when a group was expanded it would always return 1, while when the group was collapsed it would give me the number of rows in the group.  After that a little simple division worked wonders and fixed my issue:
iif(RowNumber("matrix_RowGroup")/CountRows() Mod 2, "LightGrey", "White")

Thursday, September 18, 2008

How to alternate colors in a Matrix even when RowNumber doesn't work

Most of the time you can easily alternate colors using:
Table: =iif(RowNumber(Nothing) Mod 2,"Green","White")
Matrix: =iif(RowNumber("Matrix_RowGroup") Mod 2,"Green","White")

The above is by far the most popular method of accomplishing the task, it is widely known and very simple.  However it has one major downfall, when the matrix doesn't receive any data for a specific cell it must generate a blank cell, when that happens the RowNumber count does not get auto incremented which can really throw the coloring off.

Chris Hays came up with a great workaround hack to this issue.  You can create a static grouping at the lowest level and use RunningValue to calculate an alternating value for the group header cell, then hide the cell and point the data cells BackgroundColor to the value of the group header cell.
=iif(RunningValue(Fields!Country.Value,CountDistinct,Nothing) Mod 2, "AliceBlue", "White")

I would highly recommend visiting Chris's blog where he gives step by step instructions on how to accomplish the task.

Tuesday, June 17, 2008

Reporting Services matrix alternating column colors

Since the matrix has dynamic columns the value for its background color has to be calculated rather than simply applied through the tools GUI. I figured it would be simple using RowNumber(Nothing), but I got this error when I tried:

Error 1 ... The BackgroundColor expression for the textbox ... has a scope parameter that is not valid for RunningValue, RowNumber or Previous. The scope parameter must be set to a string constant that is equal to the name of a containing group within the matrix ...

After fighting with it for a bit I searched msn and found this:

[quote]
The RowNumber function can’t be used in the whole matrix. But it can be used in the groups. So please replace the nothing with the name of the rows group. For example: =IIF(RowNumber(“rows_group_name”) Mod 2,"gray","white")
[/quote]

That ended up working great for me, however it appears that if you have a more complicated matrix you might need to take some additional tips from this page:
Green-Bar Matrix

Thursday, June 12, 2008

CSS hack for viewing reporting services in FireFox

**** CSS Fix For FireFox ***

Source Page

Add the following CSS to this file:
C:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportManager\Styles\ReportingServices.css

/* Fix report IFRAME height for Firefox */

.DocMapAndReportFrame
{
min-height: 860px;
min-width: 1024px;
}