I. Overview
1. Expected effect
Under normal circumstances, rankings are achieved through ranking and ranking within the group.
But sometimes, users need to realize: In the reporting mode, when the ranking status function of a certain column value is "dynamically changed" according to the difference of the input value, the above method cannot be satisfied. The expected effect is as follows:
2. Realization idea
The transformation is achieved through the built-in rank() function of the report.
RANK(number,ref,order): Returns the rank of a number in an array. (If you sort this array, the rank of the number is its serial number in the array.)
Parameter Description:
number: the number of the required rank (it can be Boolean, true=1, false=0)
ref: It can be an array, a reference, or a series of numbers. The value of a non-real number is ignored. (Boolean type is accepted, true=1, false=0)
order: specify the parameter for rank, non-zero means ascending order, zero means descending order
II. Example
1. Prepare data
Create a new normal report, create a new built-in dataset, and add two new fields: "Name" and "Score", and the types are "String" and "Integer" respectively. As shown below:
2. Design report
Drag the field into the corresponding cell, and the design table is as shown in the figure below:
1) Add a number widget to cell C2
2) Enter the formula in cell D2: B2+C2
3) Enter the formula in cell E2: rank(D2, D2[!0], 0), where D2[!0] represents all cells expanded by D2
Note: Among them, B2 and C2 need to be in digital format by default to achieve ranking. If B2 and C2 cells are in other formats, the following picture will appear:
At this time, enter the formula sum(B2+C2) in cell D2 to solve the problem of garbled ranking.
3. Save and preview
Save the template, click "Data Entry Preview", the effect is consistent with the expected effect in section I.1.
Note: Both App and H5 are supported.
III. Completed template
Refer to the completed template:%FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\BasicApplication\Dynamic_ranking.cpt
Click to download: