Symptom
- How to always display a minimum number of row on a report?
- In Crystal Reports, how to always print a mimimum number of rows on a report regardless the report returns no data, or only few rows?
- Note: Images and sample report data in this SAP Knowledge Base Article is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.
Environment
- SAP Crystal Reports 2013
- SAP Crystal Reports 2016
- SAP Crystal Reports 2020
Resolution
- Insert the number of sections equal to the minimum number of rows to display, and conditionally suppress it based on the number of data returned on the report. For example: If we want to always have a minimum of 7 rows:
-
Open the report in Crystal Reports.
-
In the Report Footer section, add the number of new sections equal to the minimum number of section to display, minus one. In this example, add 6 sections. ( You will then have 7 Report Footer sections )
-
Right click on the first Report Footer section ( Report Footer a ) and select "Section Expert"
-
In the "Section Expert" under the "Common" tab, click on the "X-2" button of the option "Suppress (No Drill-Down)"
-
Enter a formula to suppress the section depending on the number of data the report returns, like:
If Count(<INSERT A DATABASE FIELD HERE>) < 7 Then
False
Else
True -
In the upper right corner, click "Save and close" to accept the change
-
Back on the report, right click on the second Report Footer section ( Report Footer b ) and select "Section Expert"
-
Enter a formula to suppress the section depending on the number of data the report returns.
In this second formula, you subtract by one the number total of rows. For example if the minimum to display is 7,
then the second formula will be comparing the number of value to 6, like:If Count(<INSERT A DATABASE FIELD HERE>) < 6 Then
False
Else
True -
In the upper right corner, click "Save and close" to accept the change
-
Repeat steps 7 to 9, for all the other Report Footer sections.
For the scenario where there is actually no data on the report, we need to suppress the Details section, to do so:
-
Right click on the Details section, and select "Section Expert"
-
In the "Section Expert" under the "Common" tab, click on the "X-2" button of the option "Suppress (No Drill-Down)"
-
Enter a formula to suppress the section depending on the number of data the report returns, like:
If isnull(count((<INSERT A DATABASE FIELD HERE>) )) Then
True
Else
False -
In the upper right corner, click "Save and close" to accept the change
Now the report will alway display a minimum of rows, and if there is more rows, like 10, 15 or more, it will display all the rows.
- Sample reports demonstrating the above technique is available in the Attachments section: Minimum Number of Rows.rpt
Keywords
KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To
Product
Attachments
| Minimum Number of Rows.rpt |
SAP Knowledge Base Article - Public