Question

I have a matrix in SQL reporting and I would like it to print on an A4 page. If the matrix has less than 4 columns then it fits but for more than 4 columns I would like the matrix to wrap and show only 4 columns per page. Is this possible? I am using SQL Reporting 2005 in localmode.

Was it helpful?

Solution

I found a work around:

  1. First I added a field to my datasource called column count. Because the datasource is built in a business object it was easy for me to tell how many columns of data there is.
  2. Next I created a list on my report and moved my matrix into the list.
  3. I made the group expression =Ceiling(Fields!ColumnCount.Value/4) for the list.

In short I am telling the list to break every 4 columns. This causes the matrix to be split after 4 columns.

This will not work in all scenarios and probably screws up subtotalling but it worked for my application.

Disclaimer: this was not my idea...I adapted it from Chris Hays's Sleezy Hacks.

OTHER TIPS

There is no way to intrinsically wrap columns; Mboy's solution above is very similar to what I have done in the past so I won't repeat his steps here, although I will warn you: for matrices with a large number of columns you will grow the number of pages in your report exponentially. In your case this may not be a problem; but we have found that in most cases it is cheaper ( in terms of page output) not to wrap columns.

Further to MBoy's answer, I wanted to show multiple charts on one page, but the number of charts would vary depending on the data. What I wanted was to show two charts on a row with as many rows as necessary. I did as follows:

  1. As suggested by MBoy, I created a 'Count' field called [ChartNumber] in the data that increases by one for each chart (so if I had 7 charts, rows would be numbered 1-7).
    To achieve this I used the DENSE_RANK() SQL function to create a field in my query, such as DENSE_RANK() OVER (ORDER BY [Data].[ItemtoCount]) AS [ChartNumber].
    So if I wanted a different chart for each department I might use DENSE_RANK() OVER (ORDER BY [Data].[Department]) AS [ChartNumber]

  2. I added a list to the form and bound to my dataset

  3. I then set the row group to group on =Ceiling(Fields!ChartNumber.Value/2)

  4. I then added a colum group on =Ceiling(Fields!ChartNumber.Value Mod 2)

  5. Create a chart inside the list and preview, and you should see two charts side-by-side on each row.

I used charts, but you could easily put a matrix or any other item inside the list.

Edit: A more general solution for n columns is =Ceiling(Fields!ChartNumber.Value / n) and =Ceiling(n * Fields!ChartNumber.Value Mod n)

I don't think so. I've found that exporting to excel then printing was the most flexable way of printing SSRS matrix reports I've found - esp. since most of my users know excel well.

According to MSDN, Tablix data regions do pagination horizontally in much the same way a table does it vertically, which is to say you can specify a page break on a group change. There is another MSDN article that suggests the use of a pagination expression, but this technique is already explained by MBoy so I won't repeat it, except to say that it is an endorsed technique.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top