Conditional Sum and Count

  • Last update:  2022-04-26
  • 1. Overview

    In Excel:

    "Condition count (COUNTIF/COUNTIFS)": count the number of data pieces that meet a certain condition.

    Conditional summation (SUMIF/SUMIFS): used to sum the values of specified conditions.

    In BI, you can also use combinatorial functions to realize conditional summation and counting.

    Note: cross data table calculation cannot be realized in BI, you can only calculate in one data table.

    2. Condition count

    Note: if you don't need de duplication statistics and only need to record the times, use COUNT_AGG count is enough.

    Example: calculate the number of users logged in on the activation date (de count the contact information of users logged in on the current day)

    Sample data:

    412.User retention analysis.xlsx

    2.1 Operation steps

    After uploading data, create a component, select the "User retention analysis" data set and enter the component editing interface.

    Create a calculation field and enter the field name and formula: COUNTD_AGG(IF(DATEDIF(${Earliest activation date},${Login time},"D")=0,${TEL},null)), then click "OK", as shown in the following figure:

    2021-08-18_16-12-38.png

    Formula description:

    FormulaDescription
    DATEDIF(${Earliest activation date},${Login time},"D")Calculate the time difference between the login time and the earliest activation time, and return the time difference in days
    IF(DATEDIF(${Earliest activation date},${Login time},"D")=0,${TEL},null) If the time difference = 0, i.e. log in on the activation date, the "TEL" of the user will be output; otherwise, null will be output, i.e. no counting will be performed
    COUNTD_AGG(IF(DATEDIF(${Earliest activation date},${Login time},"D")=0,${TEL},null))Decount the contact information of the login user on the current day

    2.2 View the effect

    Drag the "Earliest activation time" into the horizontal axis and set it as "Year Month". Drag the "Number of logged in users on the activation day" field into the vertical axis to see the number of logged in users on the activation day, as shown in the following figure:

    2021-08-18_16-27-44.png

    3. Conditional summation

    Example: calculate the total amount of "profit" with "area" as "Beijing", and "sales channel" as "supermarket".

    Sample data:

    316.AC-sales.xlsx

    3.1 Operation steps

    Create a dashboard, select the "AC-sales" dataset, create a "calculation indicator", and enter the field name and formula: SUM_AGG(IF(${area}="Beijing"&&${sales channel}="supermarket",${profit},0)), as shown in the following figure:

    2021-08-18_16-30-48.png

    Formula description:

    FormulaDescription
    (IF(${area}="Beijing"&&${sales channel}="supermarket",${profit},0) If the "area" is "Beijing", and "sales channel" is "supermarket", the "profit" is output; otherwise, 0 is output
    SUM_AGG(IF(${area}="Beijing"&&${sales channel}="supermarket",${profit},0))Sum the results of the previous step

    3.2 Effect view

    After saving the indicator, drag the "Beijing Supermarket Profit" indicator into the "indicator" field to see the total collection amount under the specified conditions, as shown in the figure below:

    2021-08-18_16-32-58.png

    附件列表


    主题: Advanced Data Analysis
    Previous
    Next
    • 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