Restarting Sequence Number Generation on Each Page

  • Last update:November 13, 2023
  • Overview

    Problem

    If you directly use the seq() function, sequence numbers on one page are increased based on the sequence numbers on the previous page. As shown in the following figure, the last sequence number is 54 on the first page, and the first sequence number is 55 on the second page.  

     每页序号重新开始 图1.png

    When can you do if you want to start the sequence number from 1 on each page during report pagination preview? The effect is shown in the following figure.

     每页序号重新开始 图2.gif

    Solution

    Although original sequence numbers are incremental, each row has a unique sequence number. Based on original sequence numbers, you can start sequence numbers on each page from 1 by determining the position of the current sequence number on this page.

    Example

    Data Preparation

    Create a template and create a new data query through SELECT * FROM OrderDetails_new.

     每页序号重新开始 图3.png

    Report Design

    (1) Drag fields to corresponding cells, insert the formula seq() into cell A2, set Left Parent Cell to B2 for cell A2, and select Repeat Title Row for the first row.

     每页序号重新开始 图4.png

    (2) Insert another sequence number column next to the sequence number column, insert the formula if(COUNT({A2})=1,1,inarray(A2,{A2})) into cell B2, and set Left Parent Cell to C2 for cell B2. In the formula, {A2} obtains all the values expanded from cell A2 on the current page. If only one value is obtained after expansion, the result is 1. Otherwise, the result is the current position of cell A2's value in the {A2} array. If only one row exists on a page, {A2} obtains a value that will not be processed as an array. The second parameter in inarray must be an array, which requires judgment.

     每页序号重新开始 图5.png

    (3) Set Left Parent Cell to None for cell C2, and hide column A, as shown in the following figure.

     每页序号重新开始 图6.png

    Effect Preview

    PC

    Save the template and click Pagination Preview. The effect is the same as that shown in section "Problem."

    Mobile Terminal

    The preview effect on the app/HTML5 terminal is the same, as shown in the following figure.

     .

    Template Download

    For details, you can click to download Restarting Sequence Number Generation on Each Page.cpt.


    Attachment List


    Theme: Report Features
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

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

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

    不再提示

    7s后關閉

    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