If DataWindow expression function
Description
Evaluates a condition and returns a value based on that condition.
Syntax
1 |
<span>If</span> ( <span>boolean</span>, <span>truevalue</span>, <span>falsevalue</span> ) |
Argument |
Description |
---|---|
boolean |
A boolean expression that evaluates to true or false. |
truevalue |
The value you want returned if the boolean |
falsevalue |
The value you want returned if the boolean |
Return Values
The datatype of truevalue or falsevalue.
Returns truevalue if boolean is true and falsevalue if
it is false. Returns null if an error occurs.
Examples
This expression returns Boss if salary is over $100,000
and Employee if salary is less than or equal to $100,000:
1 |
<span>If</span>(salary > 100000, "Boss", "Employee") |
This expression returns Boss if salary is over $100,000,
Supervisor if salary is between $12,000 and $100,000,
and Clerk if salary is less than or equal to $12,000:
1 |
<span>If</span>(salary > 100000, "Boss", <span>If</span>(salary > 12000,<br>"Supervisor", "Clerk")) |
In this example of a validation rule, the value the
user should enter in the commission column depends on the price.
If price is greater than or equal to 1000, then the commission is
between .10 and .20. If price is less than 1000, then the commission
must be between .04 and .09. The validation rule is:
1 |
(Number(GetText()) >= <span>If</span>(price >=1000, .10, .04)) AND<br>(Number(GetText()) <= <span>If</span>(price >= 1000, .20, .09)) |
The accompanying error message expression might be:
1 |
"Price is " + <span>If</span>(price >= 1000, "greater than or <br>equal to", "less than") + " 1000. Commission must be<br>between " + <span>If</span>(price >= 1000, ".10", ".04") + " and " + <span>If</span>(price >= 1000, ".20.", ".09.") |