New approach to the production of irregular statistical statements grouped by paragraph

Source: Internet
Author: User

In report development, there are often reports that require unconventional statistics, fixed groupings, repeatable groupings, group sorting, and reports that are calculated across row groups, and even reports that have no data sources and need to recalculate data sources. These reports are inherently specific and often difficult to implement using conventional methods.

For grouped reports by segment, there can be duplicates between paragraphs, and grouped reports that can be duplicated by segment may occur. The collection report is simple to complete such special statistical reports, where an example is given to illustrate the implementation process.

Report Description

According to the employee Basic information table according to age statistics of the number of age groups, bonuses and other summary. The report style is as follows:


here the "30-40-year-old" and "35-45"-year-old two intervals are duplicated. The following is a comparison of the implementation of the dry report and the accounting report differences.

The trouble with this report is that the groupings that need to be done are duplicated, and the report is designed to perform more complex data calculations, but the general reporting tools are less computationally capable, and it can be quite complicated to do this with the report tool itself, for example, using a dry report:

in the dry report, this type of report is mainly through the Ds.enumgroup () function, report template and expression as follows:

where the A2 cell expression is:

=ds1.enumgroup (True,age (BIRTHDAY) >20&&age (BIRTHDAY) <=30, " aged up to ", Age (BIRTHDAY) >30&&age (BIRTHDAY) <=40," aged (BIRTHDAY) >=35&&age (BIRTHDAY) <45, " seven to three years old ", age ( BIRTHDAY) >=45, " more than three years old ")

Run Dry report in the implementation of the use of the Ds.enumgroup () function, when the group is less time to do is relatively simple, this is the other reporting tools can not be compared to dry report aspects. But when the grouping is more, the calculation is more complicated, the dry report is more difficult to realize. The reason for this is that the data source preparation and rendering of the report is mixed together, often need to implement a large number of computational tasks in the report template, if the two parts, namely: The Independent computing layer responsible for data source preparation (complete complex calculation) and the independent presentation layer responsible for report rendering, it will make report development clearer.

So, the other way is to prepare the data in advance, the reporting tools only need to be responsible for rendering and simple calculation. But whether you're programming with complex SQL, stored procedures, or custom Java datasets, it's a lot of work and difficult to maintain for such a complex operation, which is often more cumbersome than this example.

The collection report itself has a script for structured computing that makes it easy to write the calculations for data preparation (which is equivalent to a more user-friendly custom dataset). The above report requirements can be done using a collection report.


Writing a collection script

To write a set-up script using the set-up Script Editor , create a new data source Demo2:


Write a script to complete the calculation by Segment group Rollup:

A1: Connecting data source Demo2;

A2: Take employee table data;

A3: Adds a Date field and calculates the fill based on the date of birth;

a4-a5: Specify the segment interval and the interval name, where A4 and A5 content can be passed by parameter;

A6: Thea.enum () function provides the @r option to allow duplication in the grouping by completing the grouping for a given age period;

A7: Summarize employee salary, bonus and other data;

A8: Returns a result set for the report.

edit a report template

Use the Collection report editor to set up a data source for report preview:


Create a new report template and set up the collector DataSet to invoke the edited script file above

where the DFX file path can be either an absolute path or a relative path, relative paths are configured in the relative option of the DFX home directory.

report templates and expressions are as follows:

As you can see, you can use the collector script to quickly complete such a special grouping report. Moreover, the external set-up script has a visual editing and debugging environment, and the edited script can be reused (called by other reports or programs). However, if the script has been debugged and does not need to be reused, it would be cumbersome to maintain the consistency of the two files (both the set and report templates), which makes it easier to use the script dataset directly for the set report.

In a script dataset, you can step through a script to complete a calculation task, with the syntax consistent with the concentrator, and you can use the data sources and parameters that the report defines well. Using the second reporting requirement as an example, you can do this with a script dataset:

1. Click the "Add" button in the DataSet Settings window to pop up the dataset Type dialog and select "Script Data Set";

2. Write the script in the Popup Script dataset editing window;

as you can see here, the data source demo that is defined in the report is used directly in the script dataset, which is simpler and more straightforward than a separate set-up script.

3. Report templates and expressions are consistent with the use of the Collector dataset, and no longer repeat them.


New approach to the production of irregular statistical statements grouped by paragraph

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.