COUNT Function

  • Last update:April 14, 2025
  • Overview

    Function Role

    The function counts the number of items contained in an array or data area, such as Number of Regions and Number of Salespersons, as shown in the following figure.

    012.png

    The function can also be nested with other functions to perform different calculations. For example, you can use this function to perform a conditional counting to count the number of salespersons other than Jack, as shown in the following figure.

     count2.png

    In report design, you can use the COUNT function to count the number of cells, the number of cells extended from a cell, and the number of elements in an array.

    iconNote: 
    The distinct count can be achieved by combining the COUNT function with the UNIQUEARRAY() function, such as count(UNIQUEARRAY(A1)).

    Function Explanation

    Syntaxcount(value1,value2,...)  To count the number of the items in an array or a data area.
    Parameter 1   value1,value2,... The parameter that can contain any type of data.

    Example: 

    If five cells with data are expanded from cell A1, the execution result of count(A1) is 5. 

    If data exists in cells from A1 to A8, the execution result of count(A1:A8) is 8. 

    The execution result of count(2,3,4,5,7) is 5. 

    Notes

    Counting objects can be arrays or cells, and cells can be cell areas or extended cells.

    The count function counts null values caused by empty strings, but it does not count null values caused by NULL values.

    Resolvable text values, logical values, zero values, and blank cells in arrays or reference parameters will be involved in the calculation. 

    Unresolvable text values in arrays or reference parameters will not be involved in the calculation.

    Distinct Count

    Template Preparation

    Create a template, enter the SQL statement SELECT * FROM Sales_Volume to create a dataset named ds1, set the following template style, and drag the Region and Salesperson fields in ds1 into cell A2 and cell B2, respectively. Enter the formulas =count(A2) and =count(B2) in cell C2 and cell D2, respectively, as shown in the following figure.

     count3.png

    Data Column Display Setting

    The COUNT function can only count the number of cells. Since the duplicate data exists in the data columns of Region and Salesperson, if you want to count the number of regions and salespersons, you need to set the values of Data Setting to Group for cell A2 and cell B2, equivalent to the operation of distinct count, as shown in the following figure.

     count4.png

    iconNote: 
    If you select List as the values of Data Setting while pursuing the result of the distinct count, you can use the formula count(UNIQUEARRAY()).

    Cell Expansion Setting

    Set Left Parent Cell to None for cell C2. Otherwise, cell C2 and cell D2 expand along with cell B2, resulting in incorrect counting. The following figure shows the setting method.

     013.png

    Effect Display

    Save the template, and the effect is the same as that shown in section "Function Role."

    Conditional Count

    When the parameter value in the COUNT function is an expanded cell, the function can be nested with other functions to achieve a conditional count. The format is count({}), and the content in {} is the counting condition.

    For example, count(A1{A1!=0}) counts the number of cells that are expanded from cell A1 and contain data other than zero.  

    count(A1{len(A1) != 0}) counts the number of cells that are expanded from cell A1 and contains data.

    Enter the formula =count(B2{B2!='Jack'}) in cell E2 in the template to achieve the effect shown in section "Distinct Count", as shown in the following figure.

     014.png

    Save the template, and the effect is the same as that shown in section "Function Role."

    If you need to make multi-conditional judgments, you can nest formulas. For example, if you want to count the number of salespersons (other than Jack) whose sales region is New York, you can use the formula: count(B2{B2!='Jack'&&A2='New York'}) or count(B2{AND(B2!='Jack',A2='New York')}), as shown in the following figure.

    015.png

    The following table describes the formula.

    FormulaDescription
    B2!='Jack'&&A2='New York' or AND(B2!='Jack',A2='New York')  To count the number of salespersons (other than Jack) whose sales region is New York

    count(B2{B2!='Jack'&&A2='New York'}) or

    count(B2{AND(B2!='Jack',A2='New York')})

    To count the number of salespersons (other than Jack) whose sales region is New York.
    iconNote: 

    1. You can use the OR function to count the number of items that meet any condition in the formula.

    2. You can to use the COUNTIFS function in the 11.0.4 version.

    Template Download

    For details, you can download the template COUNT Function.cpt

    Attachment List


    Theme: Report Features
    Already the First
    Already the Last
    • 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