I. Overview
1. Expected effect
In the document Grouped by Section, through "Group>Advanced>Custom>Conditional Grouping", grouping and summarizing by fixed age group is realized. Now we hope to realize the data grouping dynamically according to different segment length parameters. Results as shown below:
2. Realization ideas
This can be achieved by "Group> Advanced> Custom> Formula Grouping" in "Cell Element> Data Setting".
II. Example
1. Data preparation
Create a new normal report, create a new dataset ds1, the SQL query statement is:
SELECT Age,count(1) as Count FROM EmployeeInformation group by Age. As shown below:
2. Report design
1) The design table is shown in the figure below:
2) Set the data of cell B2 to "Summary>Sum", as shown in the figure below:
3. Parameter pane setting
1) Drag in a "label widget" and "number widget" in the parameter pane, set the widget value of the "label widget" to "Section length:"; the widget name of the "number widget" is "num", and the label name is "section length:". As shown below:
2) Click "Predefined Widget" and drag the "Query Button" into the parameter pane, as shown in the figure below:
4. Group setting
Select cell A2, set the data to "Group>Advanced>Custom>Formula Grouping", select the display mode as "Ordinary Grouping", enter the formula in the custom value: "["+((roundup($$$/$num )-1)*$num+1)+"~"+(roundup($$$/$num)*$num)+"]"
The formula description is as follows:
Formula | Description |
---|---|
ROUNDUP() | Move away from the zero value and round the number upward (the direction in which the absolute value increases). |
$$$ | The actual value of the current cell |
$num | Section length parameter |
"["+ +"]" | Concatenate brackets [], or not write |
The steps are shown in the figure below:
5. Effect preview
Save the report and click "Pagination Preview". The effect is the same as the expected effect in section I.1.
Note: Both App and HTML5 are supported.
III. Template download
Refer to completed template:%FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\BasicApplication\Dynamic_grouped_by_section.cpt
Click to download:
Dynamic_grouped_by_section.cpt