Reporting Services – Determine Number of Columns Shown in Matrix

reporting-services

Is it possible to determine the number of columns displayed in a Reporting Services report, and use this within the Visibility expression of a separate textbox?

I face the following scenario:

My client has a Reporting Services 2005 report, containing a matrix, which displays a variable number of columns, depending on the parameters selected.
On occasion, some users have generated reports with a very large number of columns. This causes a server error when they subsequently attempt to export to Excel, as the Excel 97-2003 format is limited to 256 columns.

I would therefore like to display a message at the top of reports when more than 256 columns are shown in the matrix, advising users of this limitation and suggesting the workaround of exporting to CSV (and viewing in Excel 2007 if they have it).

Best Answer

Would you be able to do a count on the dataset to get your column count?

Count(Fields!FieldUsedAsColumnGrouping.Value,"DatasetName")

Not sure how your data and matrix are setup, I do something similar where I have to know the number of columns so that I can draw an appropriate border line. But I think you should be able to a Count on either the dataset or grouping to get what you are looking for. (I can paste some code come Monday if needed.)