Source: Http://community.jaspersoft.com/questions/847490/how-get-annual-growth-rate-crosstab
Each column of the crosstab is dynamically generated, it is necessary to use dynamic reference for inter-column calculation, it is difficult to implement this kind of requirement with Jasper script, it is relatively simple to use the collector in the data preparation phase, the following example is illustrated.
The database table store stores sales for a variety of products in 2014 and 2015, requires a cross-table to represent each product's annual sales volume, and calculates the annual growth rate of each product. Some of the source data are as follows:
The Collector code:
A1: Take out the store table record.
A2: Additional annual growth rate of each product. Group is grouped by product, run calculates each group of data sequentially, records append record,~ (i) indicates the record of the current group. The A2 calculation results are as follows:
A3: Returns the result of the calculation to the report. The collector provides the JDBC interface externally, and the report tool recognizes the collector as a normal database.
Design the simplest cross-table with Jasper:
You can see the results of the report after previewing:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Using Jasper report to achieve the growth rate of cross-reports