IF

  • Last update: July 17, 2025
  • Overview

    Syntax

    IF(Expression, Numeric 1/Text 1/Date 1/NULL, Numeric 2/Text 2/Date 2/NULL)

    Performs conditional judgment and returns one value if the expression is true and another value if the expression is false.

    Parameter 1

    Expression

    Expression is allowed to be a numeric or a Boolean expression.

    Parameter 2

    Returns Numeric 1/Text 1/Date 1/NULL if the expression is true.

    Parameter 2 and Parameter 3 should be of the same data type. 

    • When one of the parameters does not exist, manually enter it as NULL. If the other specifies a concrete data type, NULL aligns with the data type of the other parameter. Example: IF(xxxx=0, NULL, Parameter) .

    • When both parameters are manually entered as NULL, their types are still considered identical.

    Data type explanation:

    • Types including int, long, float, and double are all regarded as numeric types. If they coexist, the one with higher precision is adopted.

    • Types including timestamp and date are both regarded as date types. If they coexist, the one with higher precision is adopted.

    • Varchar types of different lengths are all regarded as text types.

    • Boolean is regarded as a Boolean type.

    Parameter 3

    Returns Numeric 2/Text 2/Date 2/NULL if the expression is false.

    Return Value Type

    It is determined by the formats of Parameter 2 and Parameter 3.

    Numeric

    Text

    Date

    Boolean

    Example

    You can download the example data: Order Detail.xlsx.

    For example, you want to determine if a product is high-priced or low-priced.

    Add a Data Transformation node, drag in a DB Table Input operator, and use it to read data from the example table. Add a New Calculation Column operator, set the field name to IF_Function, and click Add Field Value to enter the formula editing page, as shown in the following figure.

    3-1.png

    Input the formula IF(#{Cost_Price}>20,"High Price","Low Price"), as shown in the following figure. This evaluates products with a cost price exceeding 20 as "High Price", and others as "Low Price."

    iconNote:
    Fields in the formula need to be selected from the left area and cannot be entered manually.

    3-2.png

    Click Data Preview to view the new column, as shown in the following figure.

    3-3.png

    Further Reading

    附件列表


    主题: Data Development - Scheduled Task
    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