What is data set parameter? And how to design it in our report designer? Hope this article can help you in some extent.

1. Data set parameter principle

In industries like communication and monitoring, a massive of data will be generated every day and the total data volume in database table will be extremely large. However, in a report, it is common that you only need hundreds of pieces of data at current day.

If a report parameter is used, you have to fetch all data and then filter them, which will be extremely time-consuming;

Simple application

When defining data set sql in Finereport business intelligence, you can directly use where condition to filter all required data so as to greatly shorten report fetch time. Like sql below:

SELECT * FROM Sales Volume where Area = ‘${Area}’

Application with formula

In data set sql, you can use a parameter macro ${} for dynamic generation of filter conditions. The statement in ${} will be executed in FineReport. Combine the ${} execution result with the sql statement to form a final query statement and send it to the database for execution. You may use several ${}, as shown below:

SELECT * FROM Order where 1=1 ${if(len(area) == 0,””,”and Shipper Area = ‘” + area + “‘”)} ${if(len(province) == 0,””,”and Shipper Province = ‘” + province + “‘”)}

All built-in FR formulas can be used in ${}, like if function;

In ${}, except FR built-in function names and constants, all other variables are data set parameters.

As shown in the above SQL statement, if formula is a FR built-in formula, and the variable area is the data set parameter. If len(area)! =0, then area parameter is not Null. For example, if area value is East China, and the execution result of if statement will be “and Shipper Area = ‘East China’”. Then, combine this statement to SQL statement, and the SQL statement will be:

SELECT * FROM Order where 1=1 and Shipper Area= ‘East China’

2. Creating steps

2.1 Open report

2.2 Define data source parameter

Change the data set SQL statement as SELECT * FROM Sales Volume where Area = ‘${Area}’. Click the Refresh button at bottom to display parameters. Default value is set to “North China”:

Note: In data set SQL statement, use ${para} as a parameter macro, where the variable para is the parameter name. If the field value is a character string, add quotes, such as ‘${para}’.

2.3 Filter data

If the value in parameter area is North China, the final value of ${Area} parameter macro will be North China, and the data set SQL will be SELECT * FROM [Sales Volume] where Area = ‘North China’;

it can be seen that, in data set fetch, data will be filtered based on data source parameter; therefore, there is no need to set additional data column for filtering.

2.4 Create parameter interface

The default parameter interface is still used here.

Note: As the default value of data set parameter cannot be directly transferred to the parameter panel control, you need to additionally set the control default value. For details, refer to Control Default Value.

2.5 Save and issue reports

Save report and view the effect via Page Break Preview.

Note: If there are several data sets in the template and the defined parameter names are same, a common parameter control can be used in the Parameter Interface. That means, if the data source parameter names are same, only one parameter control needs to be defined.