Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Controlling the number of rows per page in Reporting Services Part two of a four-part series of blogs |
---|
Unfortunately, Reporting Services doesn't have a simple setting that allows you to control the number of rows you see on each page. However, you can control this using a clever combination of an expression with a grouping level. Read this blog to find out how!
|
In this blog
The most accurate way to control the number of records on a page in a report is to combine grouping with a simple expression. This part of the blog series explains exactly how to make this technique work.
For our example we'll create a simple report with a table containing a list of 263 films. Our aim is to make each page of the report display only 10 rows. The design of this report is shown in the diagram below:
This is the basic design of the report. For demonstration purposes we've added an expression to calculate the row number of each record in the table.
The expression that we've used in the Row column is shown in the diagram below:
The RowNumber function calculates the number of each row in the current table. We don't need to include it here but it helps to demonstrate the effect.
The results of running this report are as follows:
The report contains 6 pages. The first 5 pages contain 48 rows and the final page contains 23 rows, making a total of 263 records.
The next step is to add a grouping level to the table using the groups panel at the bottom of the screen:
Right-click on the (Details) row and choose Add Group > Parent Group...
On the dialog box that appears, click the button shown in the diagram below to launch the Expression Builder dialog box:
Click the fx button shown here to launch the Expression Builder.
In the next dialog box, enter the calculation shown below and click OK.
The number 10 in this expression ensures we see 10 rows per page, but you can change this value if you want to.
Click OK once more to apply the grouping level to the table.
Click OK again to apply the grouping to the table.
If you try to preview the report at this stage you'll receive an error message similar to the one shown below:
The error message you'll see when you preview the report.
To prevent this error from happening we need to remove the automatic sort that has been applied to the group. Start by right-clicking on the group in the panel at the bottom of the screen:
Right-click on the group name and choose Group Properties...
Complete the dialog box which appears as shown below:
The numbered steps are described below.
You should now find that when you preview the report you can see all of the data in groups of 10 rows.
Each set of 10 rows has a different value in the Group1 column.
The next step is to put each group on a separate page.
To add a page break between each group, right-click on the group name in the panel at the bottom of the screen:
Right-click the group name and choose Group Properties...
Complete the dialog box which appears as shown below:
The numbered steps are described below.
When you preview the report you should find that you have the specified number of records per page.
We get the exact number or records we require on each page, at the cost of having more pages in the report.
To tidy things up you could delete the first two columns in the example shown above - neither are required to make this technique work.
At this point you know everything you need to make this technique work for any number of records per page (up to the maximum that the page size can handle). If you're interested in how the expression we've used actually works you can read the next part of this blog series to find out!
Parts of this blog |
---|
|
Some other pages relevant to the above blogs include:
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.