Saturday 2 January 2016

SSRS - Page Break at Nth row in SSRS Report

We can design a SSRS report with a constraint of only Nth rows per page.

I am showing you that how to display only Nth rows in the report in this article.

Here is an example from  AdventureWorks Database.

SQL Scripts.

SELECT TOP 1000 [StateProvinceID]
      ,[StateProvinceCode]
      ,[CountryRegionCode]
      ,[Name]
      ,[rowguid]
      ,[ModifiedDate]
  FROM [AdventureWorks].[Person].[StateProvince]

Select the Header Row of the table in the report.
Go to Properties Window.
 Under the BackgroundColor property, Select color from drop down.


Now create a group.



After creating the group go to the group properties and click on fx button.



And set the expression for group properties.



Expression :
=Ceiling((RowNumber(Nothing)) / 15)

( Note : You can put Nth number in place of 15. For example if you want to your page break affect after each 25th row than you have to put 25 in place of 15 )  

 Now, report will show 15 rows in a group. Next step is to define page break for the group. Go to page breaks tab and select page break option.



And now run the report. Below the preview of report.


OR

This implementation topic has page break configuration in the report.
Step 1: A simple design to show all rows in a table using table component.
Step 2: Add a parent group to the detail row
Step 3: Add group expression “=Ceiling((RowNumber(Nothing)) / Nth row)” i.e. “=Ceiling((RowNumber(Nothing)) /50)” and Click OK
Step 4: You may get the following error if you run the report after step 3.
Step 5: Open Row group properties and remove sort expression.
or explicitly cut and paste the same experssion in sort box.
Step 6: Now, report will show 50 rows in a group. Next step is to define page break for the group. Go to page breaks tab and select page break option
Step 7: Now, hide the group header and detail column from the table component and run the report.

No comments:

Post a Comment