IF
Returns one value if a logical expression is true and another value if the expression is false.
Syntax
IF(TestExpression, TrueValue, FalseValue)
TestExpression is a logical expression that can contain relational and logical operators, for example, X < Y.
TrueValue and FalseValue are numbers or strings. They can also be expressions that return a number or a string.
Note: Comparisons of string values are supported only for equality.
Examples
-
This example returns 1:
IF(1 < 2, 1, 'OK') - This example returns 'OK':
IF(1 > 2, 1, 'OK') - This example returns 'OK':
IF((2 > 1) AND (2 < 3), 'OK', 'Not OK') - This example returns 'OK':
IF(NOT(2 < 1), 'OK', 'Not OK') - This example returns 'Yes':
IF(GETATTR('Product', 'Car Tires Summer', 1, 'APRODUCT') @= 'Tanja.Saarbruecken@Genesis.com', 'Yes', 'No')TipThe comparison is case-sensitive, therefore for logical-type dimension attributes it’s recommended to convert the returned attribute value to either upper or lower case before comparing:IF(UPPER(GETATTR('ValType', 'Actual', 1, 'AFlogical1')) @= 'T', 'Yes', 'No') - This example returns 'CS' because string comparisons are case-sensitive:
IF('Infor' @= 'infor', 'CI', 'CS') - This example returns 'Always' because the = relational operator converts strings to numbers if possible:
IF('1.5' = 1.5, 'Always', 'Never') - This example returns 'Point' because the decimal point is a point and not a comma:
IF('3,14' = 3.14, 'Comma', 'Point')