Monday, March 14, 2011

How to fix number of rows per page in SSRS

Recently while working on a SSRS project where we had requirement to limit the number of records in report per page. This was something basically needed to improve the report visibility in the SharePoint page. If we fix the number of records per page in the report then we can control the height of the report and can avoid the vertical scroll bar in the report as well.
In this example I am going to show the 25 rows per page in the report…The steps are mentioned below to achieve this functionality.

1. Add a Row Group (Parent)










2. In the group enter the expression, =CEILING(RowNumber(Nothing)/25)











3. In the above expression 25 is the number of records displayed per page.
4. The CEILING function returns the Returns the smallest integer greater than, or equal to, the given numeric expression.
http://msdn.microsoft.com/en-us/library/aa258240(SQL.80).aspx
5. The RowNumber Returns a running count of the number of rows for the specified scope.
http://msdn.microsoft.com/en-us/library/ms159225.aspx
6. Since we are using “Nothing”, the RowNumber will consider the outermost data region, this can be replaced with the name of the specific data region.
7. Once the group is created, go to the Group properties-->Page Breaks and select the check box “Between each instance of a group”












8. Make sure you have removed the sorting from the Group Properties since in this case this will cause an error.
9. Now at last we can delete the first column which was created when the Group was added since we do not need to display anything here. Please make sure to select the “Delete Columns Only” option while deleting the column.













10. Run the report and it should return 25 records per page.

Hope this article helps…please leave the comment if this is not clear or if you have any questions on this.

Thanks,
Gaurav

14 comments:

  1. What if you are using interactive sort?

    ReplyDelete
  2. Hi,

    I want the report to fire fast. It will show the top 25 rows then after clicking on next the sp will fire again and bring the next 25 rows. Just like paging in dotnet Is it possible. If yes then how.

    ReplyDelete
  3. Hello Gaurav
    when I trying this process,I didn't get any success.Error is following....
    "[rsRowNumberInSortExpression] A sort expression for the tablix ‘Tablix1’ uses the function RowNumber.RowNumber cannot be used in sort expressions".

    I am not using any sorting expression.

    ReplyDelete
    Replies
    1. right click on the group-->GO TO sorting and remove any sorting that is there.

      Delete
  4. this work for direct select
    but when matrix pivot rows as columns
    it dosen't work correctly
    can any one help me

    ReplyDelete
  5. [rsRowNumberInSortExpression] A sort expression for the tablix ‘table1’ uses the function RowNumber. RowNumber cannot be used in sort expressions.

    how to edit it works.

    Thank

    ReplyDelete
  6. An error occurred during local report processing. The definition of the report 'Report' is invalid. a sort expression for the tablix 'table' uses the function Rownumber. Rownumber cannot be used in sort expressions.

    ReplyDelete
  7. What if i want to show more records like 200 in one page? It's not working using your procedure. Also it breaks the flow of records while exporting to pdf.

    ReplyDelete
  8. Hi All,

    When we try to export the report to pdf or word, we are getting 19 or 18 records in the first page and the second page contains rest of the records (6 or 7 records) -- for a total of 25 records. The half of the second page gets filled with data and rest remains blank. The third page starts with 26 record.

    Please advice.

    ReplyDelete
  9. Since each data row actually shows as 4 rows on the report I tried this with /7. Instead of putting 28 rows on each page it only showed every 7th row and did noting to limit the amoutn of rows on a page.

    ReplyDelete
  10. A sort expression for the tablix ‘Tablix1’ uses the function RowNumber. RowNumber cannot be used in sort expressions.

    ReplyDelete
  11. I do this and I get 1 page for each row.

    ReplyDelete
  12. A sort expression for the tablix ‘Tablix3’ uses the function RowNumber. RowNumber cannot be used in sort expressions.

    ReplyDelete
  13. A group function is does not work in perviously group...

    ReplyDelete