Limit the Number of Records Returned
Say you have a report that returns a large amount of data and you want to see only a sample number of rows. You can easily do this by creating a data item with a running count of a column in the report (i.e. UST_ID). Then add a filter in the query (e.g. Data Item <= 100). You can also set this up as an optional prompt allowing you to choose the number of records you’d like to view each time the report is run.
- In the Query Explorer double click on the tabular model of your main query.
- From the Toolbox, drag a Data Item into the Data Items pane of the query.
- In the expression definition box type the following:
running-count([STUDENT_ID])
- Name the Data Item Running-Count.
- From the Toolbox drag a filter into the Filters pane and type in this expression:
[Running-Count]<= 100.
When you run your report only the first 100 records will be returned.
To make this a prompt:
- From the Page Explorer select your prompt page or create one if the report does not have one.
- From the Toolbox drag a Text Box Prompt to your prompt page.
- Select Create a New Parameter and name the parameter record_limit.
- Click finish.
- In the Query Explorer double click on the tabular model of your main query.
- Select the Running-Count filter and change the expression to:
[Running-Count]<=?record_limit?
- Make this filter optional by opening Page 1 from the Page Explorer and selecting the filter icon.
When you run your report you will be prompted for a number to enter. If left blank the report will return all records.
The following logic will accomplish the same task without using a query item from the report.
- Create a data item called Rows: running-count(count(rows))
- Then filter the query: [Rows] <11
This will give you 10 rows without referencing any of the query items within the report.