If
Excel
=~IF!~(‹logical_test›, ‹when_true›, ‹when_false›) OR (multiple conditions) =~IF!~(‹logical_test1›, ‹when_true1›, ~IF!~(‹logical_test2›, ‹when_true2›, ‹when_false2›))
=IF(A1 >= 10000, "Large", "Small")
=IF(B1 > 0, "Profitable", IF(B1 = 0, "Breakeven", "Unprofitable"))
Tableau
~IF!~ ‹logical_test› ~THEN!~ ‹when_true› «ELSE when_false» ~END!~ OR (multiple conditions) ~IF!~ ‹logical_test1› ~THEN!~ ‹when_true1› ~ELSEIF!~ ‹logical_test2› ~THEN!~ ‹when_true2› ~ELSE!~ ‹when_false› ~END!~
IF [Records] >= 10000 THEN "Large" END
IF [Profit] > 0 THEN "Profitable"
ELSEIF [Profit] = 0 THEN "Breakeven"
ELSE "Unprofitable"
END
Alteryx
~IF!~ ‹logical_test› ~THEN!~ ‹when_true› ~ELSE!~ ‹when_false› ~ENDIF!~ OR (multiple conditions) ~IF!~ ‹logical_test1› ~THEN!~ ‹when_true1› ~ELSEIF!~ ‹logical_test2› ~THEN!~ ‹when_true2› ~ELSE!~ ‹when_false› ~ENDIF!~
IF [Records] >= 10000 THEN "Large" ELSE "Small" ENDIF
IF [Profit] > 0 THEN "Profitable"
ELSEIF [Profit] = 0 THEN "Breakeven"
ELSE "Unprofitable"
ENDIF
OrgVue
~if!~(‹logical_test›){‹when_true›} ~else!~{‹when_false›} OR (Shorthand / ternary syntax) ‹logical_test› ? ‹when_true› : ‹when_false› OR (multiple conditions) ~if!~(‹logical_test1›){‹when_true›} ~else if!~(‹logical_test2›){‹when_true2›} ~else!~{‹when_false›}
if(node.employees.count >= 10000){"Large"} else{"Small"}
OR (Shorthand / ternary syntax)
node.empoyees.count >= 10000 ? "Large" : "Small"
OR (multiple conditions)
if(node.profit > 0){"Profitable"}
else if(node.profit == 0){"Breakeven"}
else{"Unprofitable"}
tSQL
~IF!~ ‹logical_test1› ~BEGIN!~ ‹when_true1› ~END!~ (Repeat above code for IF...ELSE statement)
SELECT Profit
IF Profit > 0 BEGIN "Profitable" END
ELSEIF Profit = 0 BEGIN "Breakeven" END
ELSE "Unprofitable"
FROM SalesData
Python
In the example below, new line breaks and indents are needed for the syntax to work correctly (line indentation takes the place of curly braces {}
in Python). Indents are four spaces.
~if!~ ‹logical_test›:
‹when_true›
~else!~:
‹when_false›
OR (multiple conditions)
~if!~ ‹logical_test1›:
‹when_true1›
~elif!~ ‹logical_test_2›:
‹when_true2›
~else!~:
‹when_false!~
if len(employees) >= 10000:
"Large"
else:
"Small"
// OR (multiple conditions)
if sum(profit) > 0:
"Profitable"
elif sum(profit) == 0:
"Breakeven"
else:
"Unprofitable"
NB. The above example assumes a variable has been declared for profit
. For more information, go to General > Variables.
Last updated
Was this helpful?