COUNTIFS — Conditional Counting

  • Last update:September 24, 2025
  • Overview

    Version

    Report Server Version

    Functional Change

    11.0.4

    Added the COUNTIFS function.

    11.0.7

    Adapted the COUNTIFS function to the chart module.

    Application Scenario

    The COUNT function can count the items in an array or a data range. But sometimes, conditional counting is required to count the data records that meet certain conditions.

    For example, you want to count the salespersons with a sales volume greater than 2000, as shown in the following figure.

    应用场景-1.png

    For example, you want to count the months in the current year with a payable amount greater than 2500, as shown in the following figure.

    应用场景-2.png

    Function Description

    The COUNTIFS function is added in version 11.0.4 to implement conditional counting.

    iconNote:
    The hierarchical coordinate function only supports cell calculations and does not support cross-sheet calculations, watermarks, JavaScript references, or default parameter values.

    Function Explanation

    (1) Overview

    Syntax

    COUNTIFS(number,boolean)

    Counting the cells that meet specified conditions

    Parameter 1

    number

    Data range for counting

    Parameter 2

    boolean

    Judgement condition, whose result is true or false. You can use && and || to separate multiple conditions. When this parameter is null, the execution effect of this function is the same as that of the COUNT function.

    iconNote:

    Currently, only the following judgement conditions are supported.

    (1) Comparison of numbers, for example, >10
    (2) Comparison of strings, for example, a == "a"
    (3) Comparison of null values, for example, ==null

    (2) Example

    Example one: Cell A2 contains each salesperson, and cell B2 contains the total sales volume of each salesperson. Enter the formula COUNTIFS(A2,B2 > 2000) in cell C2, and set Left Parent Cell to None for cell C2. In this way, the salespersons with sales volume greater than 2000 will be counted. For details, see section "Example One."

    Example two: Cell A2 contains each year, cell B2 contains each month, and cell C2 contains the total payable amount of each month. Enter the formula COUNTIFS(B2,C2>2500) in cell C3, and set Left Parent Cell to Default (that is, cell A2) for cell C3. In this way, the months in the current year with a payable amount greater than 2500 will be counted. For details, see section "Example Two."

    iconNote:
    Set Left Parent Cell for the cell where the formula is located according to the actual situation. Left Parent Cell needs to be set to None for the cell where the formula is located in example one, and be set to Default in example two.

    Example One

    Template Creation

    Create a general report, as shown in the following figure.

    新建报表.png

    Data Preparation

    Create a database query ds1 with the SQL query statement SELECT * FROM Sales_Volume to extract all data from the Sales_Volume table, as shown in the following figure.

    数据准备一.png

    Report Design

    (1) Enter text in cells A1 and B1 and drag the corresponding data columns to cells A2 and B2, as shown in the following figure.

    设计报表一1.png

    (2) Select Summary and Sum in Data Setting for cell B2, as shown in the following figure.

    设计报表一2.png

    (3) Enter text in cell C1, insert the formula COUNTIFS(A2,B2 > 2000) in cell C2, and set Left Parent Cell to None for cell C2, as shown in the following figure.

    设计报表一3.png

    Effect Display

    1. PC

    Save the report and click Pagination Preview. The following figure shows the preview effect.

    效果预览一.png

    2. Mobile terminal

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

    手机端一.jpg

    Example Two

    Template Creation

    Create a general report, as shown in the following figure.

    新建报表.png

    Data Preparation

    Create a database query ds1 with the following SQL statement:

    SELECT STRFTIME('%Y',SIGNDATE) AS Year,STRFTIME('%m',SIGNDATE) AS Month,PAIDFROM ORDERS_oldWHERE STRFTIME('%Y',SIGNDATE) IN ('2008','2009')

    This indicates filtering the year 2008 or 2009 (extracting the year part from the SIGNDATE field, and naming it Year), month (extracting the month part from the SIGNDATE field, and naming it Month), and payable amount (the PAID field) from the ORDERS_old table, as shown in the following figure.

    数据准备二.png

    Report Design

    (1) Enter text in cells A1 to C1, merge cells A2 and A3, and drag the corresponding data columns to cells A2 to C2, as shown in the following figure.

    设计报表二1.png

    (2) Select Summary and Sum in Data Setting for cell C2, as shown in the following figure.

    设计报表二2.png

    (3) Enter text in cell B3, insert the hierarchical coordinate formula COUNTIFS(B2,C2>2500) in cell C3, and set Left Parent Cell to Default (that is, cell A2) for cell C3. In this way, the months in the current year with a payable amount greater than 2500 will be counted, as shown in the following figure.

    设计报表二3.png

    Effect Display

    (1) PC

    Save the report and click Pagination Preview. The following figure shows the preview effect.

    应用场景-2.png

    (2) Mobile terminal

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

    手机端二.jpg

    Template Download

    Download the completed template of example one by clicking COUNTIFS Example One.cpt.

    Download the completed template of example two by clicking COUNTIFS Example Two.cpt.


    Attachment List


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

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

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

    不再提示

    10s後關閉

    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