Dynamically Display First N Groups

  • Last update:March 24, 2021
  • I. Overview

    1.1 Problem Description

    In the report application, the grouping and summary data display only needs to display the first few categories with a relatively high proportion, and the remaining categories with a small proportion are usually merged into other categories, making the displayed table look more concise and clear. So in the case of ordinary grouping, how to dynamically display the first N groups and merge the following groups into others? Results as shown below:

    1.gif


    1.2 Realization Ideas

    In the Cell Element> Data Settings position, grouping is achieved through custom formulas.

    II. Example

    2.1 Template Preparation

    1) Create a new dataset ds1, the sql statement is:

    SELECT * FROM SALES_BASIC where Product='Television'

    As shown in the figure below:

    2.png

    2) In turn, drag the Salesperson, Product Type, Product, and Sales Volume fields in ds1 into cells A2, B2, C2, and D2 to set the template style, as shown in the following figure:

    3.png

    3) Click cell D2, select "Summary-Sum" in the "Cell Element"> "Data Settings" position, and set the data type of cell D2 to Group Sum, as shown in the figure below:

    4.png


    2.2 Set Drop-down Box Widget

    Add a drop-down box widet, which is used to select the first few groups that need to be displayed.

    1) Create a new template parameter TOPN. Click "Template", select "Template Parameters", create a new template parameter "TOPN", and select "Integer" as the default value, as shown in the figure below:

    5.png

    2) Add the TOPN parameter in the parameter panel, select the widget type as "drop-down box widget", select the data type as "formula" in the "data dictionary", and write the formula range(1,5) in the actual value, which is the drop-down box Add digital values that can be selected, as shown in the following figure:

    6.png

    Note: The RANGE (from, to, step) function represents a sequence of numbers starting from the integer from, taking step as the size of each step, up to the integer to.


    2.3 Custom Group

    1) Select cell A2, and in the "Cell Element"> "Data Settings" position, select "Group-Advanced-Custom" in turn, as shown in the figure below:

    7.png

    2) Click the "Custom" position, select "Formula Group" as the custom grouping method, select "Ordinary Grouping" as the display mode, and write the formula in the "Custom Value" position: if(inarray($$$,ds1.select( Salesperson))<=$TOPN,$$$,"Other"), merge all salespersons after the Nth salesperson into others, as shown in the following figure:

    8.png

    Formula explanation:

    StepsEffectFormula Description
    ds1.select(Salesperson)Take the Salesperson column in the ds1 datasettablename.select(colname):Select the data in a certain column of the dataset, and the return result is an array
    inarray($$$,ds1.select(Salesperson))Get the position of the current cell salesperson in the Salesperson columninarray(co,array):Returns the position of co in the array array, if co is not in the array, returns 0
    if(inarray($$$,ds1.select(Salesperson))<=$TOPN,$$$,"Other")Rename the salesperson whose position is greater than N to other

    IF(boolean,string1,string2):Judgment function, return string1 when boolean is true, and return string2 when it is false

    $parameter name: reference parameter


    2.4 Effect Preview

    2.4.1 PC

    Save the template, click "Pagination Preview", the effect is shown in section 1.1.

    2.4.2 Mobile

    The preview effect of App and HTML5 is shown in the figure below:

    9.png

    III. Template Download

    Refer to the completed template:%FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\ReportApplication\BasicApplication\Dynamically_display_first_N_groups.cpt

    Click to download:

    Dynamically_display_first_N_groups.cpt


    Attachment List


    Theme: Report Application
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    9s后關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy