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.
Expression
Expression is allowed to be a numeric or a Boolean expression.
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.
Returns Numeric 2/Text 2/Date 2/NULL if the expression is false.
It is determined by the formats of Parameter 2 and Parameter 3.
Numeric
Text
Date
Boolean
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.
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."
Click Data Preview to view the new column, as shown in the following figure.
Adding a Column Using the IF Function
Handling Missing Values
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉
Submitted successfully
Network busy