Conditional function
$If function returns one of two patterns based on expression value. It has the following parameters:
  1. Expression.
  2. Pattern 1 (expression is "true")
  3. Pattern 2 (expression is "false")

Important

  • The engine uses 0 and negative integer values as 'false' and other integers as 'true'. It converts float values to integer by truncating: '0.9' and '-9' are 'false'.
  • If the expression contains '(' and ')' please add extra brackets for whole expression.
  • We do not recommend to use string, date or time values as condition directly. Please compare it with another value instead.

Examples

  1. $If(@'CustomerID'>255,null,255) means 'null' if 'CustomerID' column greater then 255 or 'null' otherwise.
  2. $if(((@'ID'>=2) & (@'ID'<8)),10,0) generates 10 for 'ID' between 1 and 8 (i.e. 2,3,4,5,6,7) and 0 otherwise.
  3. $If(@'CustomerName'='null',$CALL(COMPANY),0) means 0 if 'CustomerID' column contains 'null' string or use named generator COMPANY otherwise.

See Also

$ifr function.