反馈已提交

网络繁忙

You are viewing 5.1 help doc. More details are displayed in the latest help doc.

IF

  • Recent Updates: May 10, 2022
  • 1. Overview

    Judge the condition. If the calculation result of the specified condition is "TRUE", the IF function will return a value; If the condition evaluates to "FALSE", another value is returned.

    GrammarIF(boolean,number1/string1,number2/string2)Judge the function and return the first non-null value.
    Parameter1boolean

    Number1 / string1 is returned when Boolean is true, and number2 / string2 is returned when Boolean is false. The second and third parameters must be of the same type. 

    Parameter2number1/string1
    Parameter3number2/string2

    2. Precautions

    • Three parameters in IF. The first is bool type or numeric type (0 or 1). The second and third parameters are of the same type. If the two parameters are empty, the non-empty parameter type is returned. The two-parameter types are different, return text type.

    3. Examples

    3.1 Usage 1

    For example, the user needs to change the "Type" to code display, the "Purchase contract" to 1, the "Long term agreement" to 2, and the other two agreements to 0.

    For example, use the "contract fact table" to add a new column in the self-service dataset. After naming, enter the formula:IF(Type="Purchase contract",1,IF(Type="Long term agreement",2,0))and click "OK", as shown in the following figure:

    1.png

    Note: the fields in the formula box need to be selected by clicking the selection area on the left, and cannot be entered manually.

    The contract type code appears in the self-service dataset, as shown in the following figure:

    2.png

    Further data examples are as follows:

    FormulaResultsRemark
    IF(true,2,8) 2
    IF(true,2,8) second
    IF("Net profit of each store">0,"good","bad") When "net profit" >0, equals to "good", when "net profit" <0, equals to "bad".

    Note: if you need to nest multiple IF functions, you'd better use the SWITCH function. This function provides a more elegant way to write expressions that return more than two possible values.

    3.2 Usage 2

    IF function can also be used in combination with other functions, such as logic function and aggregate function.


    Use the IF function to handle the case where the field is empty.
    Use the IF function to ensure that the division result is correct.
    Use the IF function to classify and assign the data.
    Use the IF function to do conditional sum counting.


    Attachment List


    Theme: Advanced Data Analyis
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    售前咨询电话

    400-811-8890转1

    在线技术支持

    在线QQ:800049425

    热线电话:400-811-8890转2

    总裁办24H投诉

    热线电话:173-1278-1526

    文 档反 馈

    鼠标选中内容,快速反馈问题

    鼠标选中存在疑惑的内容,即可快速反馈问题,我们将会跟进处理。

    不再提示

    10s后关闭