Grouping by Custom Formula

  • Last update:April 28, 2025
  • Overview

    Version

    Report Server Version

    11.0

    Expected Effect

    Typically, data is grouped according to a specific field, such as the date field, where each date corresponds to a group. However, this grouping display is overly detailed. You want to group and display the data by year and week instead, as shown in the following figure.

     图1.png

    iconNote:
    In FineReport, the calculation logic of the WEEK formula is the same as that in Excel, where Sunday is defined as the first day of a week. The first week in a year must start on Sunday.

    For example, if 2010/01/01 is a Friday, then 2010/01/01 would not be counted as the first week of 2010, but only as the last week of 2009.

    Implementation Method

    The database stores dates in the format of year-month-day. You can group the data by year and week by defining Custom Value in the Custom Group dialog box.

    Example

    Report Design

    Report Creation

    Create a general report and enter the SQL statement SELECT * FROM Orders_new to create a dataset named ds1, as shown in the following figure.

    图2.png

    Report Style

    Drag the fields into the corresponding cells, as shown in the following figure.

     图3.png

    Grouping by Custom Formula

    OrderDate Year Grouping

    Select cell A2 where the Orderdate data column is located, and select Group and Advanced for Data Setting. Click Custom to bring up the Custom Group dialog box, and select By Formula. Set Display Mode to Common Group and Custom Value to = year($$$). Set the Orderdate field to be grouped by Year and displayed as a number with year($$$) representing the year from the given date, as shown in the following figure.

     图4.png

    OrderDate Week Grouping

    Select cell B2 where the Orderdate data column is located, and select Group and Advanced for Data Setting. Click Custom to bring up the Custom Group dialog box, and select By Formula.

    Set Display Mode to Common Group and Custom Value to = "No." + week($$$) + "Week" Set the Orderdate field to be grouped by Week and displayed as "No.X (a number) + Week", with week($$$) representing the week number from the given date, as shown in the following figure.

    图5.png

    Setting Summarization

    Select the C2 cell, choose Cell Element > Basic > Data Setting, and select Summary and Sum, as shown in the following figure.

    图6.png

    Effect Display

    PC

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

    Mobile Terminal

    The preview effects on the DataAnalyst app and HTML5 terminal are the same, as shown in the following figure.

    Last.jpg

    Template Download

    For details, you can download the example template: Group by Custom Formula.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