# If

## Excel

\=\~IF!\~(‹logical\_test›, ‹when\_true›, ‹when\_false›) \
OR (multiple conditions)\
&#x20;\=\~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)\
&#x20;\~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)\
&#x20;\~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)\
&#x20;‹logical\_test› ? ‹when\_true› : ‹when\_false›\
OR (multiple conditions)\
&#x20;\~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. \
&#x20;\~if!\~ ‹logical\_test›:\
&#x20;    ‹when\_true›\
&#x20;\~else!\~:\
&#x20;    ‹when\_false›\
&#x20;OR (multiple conditions)\
&#x20;\~if!\~ ‹logical\_test1›:\
&#x20;    ‹when\_true1› \
&#x20;\~elif!\~ ‹logical\_test\_2›:\
&#x20;    ‹when\_true2› \
&#x20;\~else!\~: \
&#x20;    ‹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](https://orgvue.gitbooks.io/formula-translator/content/general/variables.html).
