Multiple result sets of report data sources and report data sources
Diverse data sources are becoming more and more common in report development. the effective support of the collection and computing reports for diverse data sources makes the development of such reports very simple, currently, in addition to supporting different types of data sources (RDB, TXT text, Excel, JSON, HTTP, Hadoop, and mongodb, you can also use multiple result sets returned for a report in a dataset. This effectively avoids repeated operations and improves report development efficiency and computing performance. The following example describes how to use multiple result sets.
Report description
Query the names and total scores of the top three and the last three students based on the student Score Table. The report style is as follows:
To display the names and scores of the top three students and the top three students respectively, the report is naturally divided into two parts. If a dataset needs to be hidden, it is relatively simple to use two datasets. a dataset is grouped and summarized based on the original data, sorted in descending order of the total score, and the top three are obtained, the second dataset takes the top three in ascending order. However, Repeated Computation (group aggregation and sorting) occurs in this process. This problem does not occur if multiple result sets are returned through the set calculator. The following is the implementation process.
Compile the computing script
Use the computing Script Editor to write computing scripts to complete data computing and data source preparation.
A1: connect to the data source demo;
A2: Execute SQL to query the student renewal table data;
A3: scores are summarized by student group;
A4: Use the. top () function to obtain the first three records based on the total score;
A5: Use the. top () function to obtain the last three records based on the total score;
A6: returns the first three records in two result sets.
Edit a Report Template
Connect to the report data source demo.
Set Dataset
Use the report designer to create a report template, set the dataset, and call the edited script. Because two result sets are returned in the script, you must manually enter the dataset name "ds1, ds2" in dataset settings. Multiple dataset names are separated by commas.
The dfx file path can be either an absolute or relative path, and the relative path is the dfx home directory configured in the relative options.
Dataset presentation form:
Set a report expression
Edit the report expression, directly use the two result sets returned by the Set Computing script, and use a simple list expression to complete report creation.
As you can see, you can use the set calculator script to output multiple result sets for the report, and the external set computing script has a visual editing and debugging environment, the edited script can also be reused (called by other reports or programs ). However, if the script has been debugged and does not need to be reused, It is troublesome to maintain consistency between the two files (the Set Computing script and Report Template, in this case, it is easier to directly use the script dataset of the Set Computing report.
In the script dataset, you can write scripts to complete computing tasks step by step. The syntax is the same as that of the Set calculator. You can also directly use the data sources and parameters defined in the report. You can use the script dataset as follows:
1. Click "add" in the dataset settings window. The dataset Type dialog box is displayed. Select "script dataset ";
2. Compile the script in the pop-up script dataset editing window.
In the script dataset, you can directly use the demo of the data source defined in the report for query, instead of using the connect () function to connect to the data source like an independent set computing script.
The report expression is the same as the dataset using the cube.