Achieving Multi-Column Sort Through Dynamic Columns

  • Last update:February 19, 2024
  • Overview

    Expected Effect

    Some users want to sort each column individually based on dynamic columns, as shown in the following figure.

     1.png

    Implementation Method

    Sort each column after setting expansions based on dynamic columns achieved by functions.

    Procedure

    Template Preparation

    1. Take the template in the document Achieving Dynamic Columns Through Functions as a basis and modify the template.

    2. Enter Number in cell A1, as shown in the following figure.

     2.png

    3. Choose Template > Repeat/Freeze, click Pagination Preview, select Repeat Title Row From No. 1 Row to No. 1 Row, and click OK, as shown in the following figure.

     3.png

    4. Modify the SQL statement of ds1 to SELECT * FROM ORDERSDETAIL.

    Dynamic Parameter Adding in Cell B1

    Select cell B1 and add a hyperlink (dynamic parameter type) to cell B1.

    Add two parameters order (value formula: if($order = 1, -1, 1)) and index (value formula: &B1), as shown in the following figure.

    iconNote:
    The value of the index parameter is &B1. That is, the value of index is the number of the clicked cell when you click the column header.

     4.png

    Sort After Expansion

    Set Sort Basis to Formula and if(isnull($index), A2, if($order = 1, EVAL("B2[;B1:" + $index + "]"), EVAL("-1*B2[;B1:" + $index + "]"))) and Sort Rule to Ascend.

    When order is 1, the values of the clicked column obtained by EVAL("B2[;B1:" + $index + "]") are sorted in ascending order. When order is -1, the values of the clicked column are first converted to negative numbers and then sorted in ascending order based on the negative numbers.

    The following table describes the formula.

    Formula
    Description

    isnull($index)

    Checks whether the value of $index is an empty string. The value of $index is empty during initialization and then is the value of &B1 (the number of the clicked cell) after you click the column header.

    Note: If the value of $index is empty, you can sort by cell A2 to improve the performance of the first column header click.

    "B2[;B1:" + $index + "]"

    Returns the value of cell B2 corresponding to the $index-the value expanded from cell B1.

    EVAL()

    Returns a string expression.

     5.png

    Effect Display

    On PC

    For details, see section "Expected Effect."

    On Mobile Terminals

    The following figure shows the preview effect on the DataAnalyst and on HTML5 apps.

     6.png

    Template Download

    You can download the example templat Achieving Multi-Column Sorting Through Dynamic Columns.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