Case DataWindow expression function
Description
Tests the values of a column or expression and returns values
based on the results of the test.
Syntax
1 |
<span>Case</span> ( <span>column</span> WHEN <span>value1</span> THEN <span>result1</span> { WHEN <span>value2</span> THEN <span>result2</span> <br> { ... } } { ELSE <span>resultelse</span> } ) |
Argument |
Description |
---|---|
column |
The column or expression whose values |
WHEN (optional) |
Introduces a value-result pair. At least |
valuen |
One or more values that you want to compare
|
THEN |
Introduces the result to be returned |
resultn |
An expression whose value is returned |
ELSE (optional) |
Specifies that for any values of column that |
resultelse |
An expression whose value is returned |
Return Values
The datatype of resultn. Returns the
result you specify in resultn.
Usage
If more than one WHEN clause matches column,
Case returns the result of the first matching one.
Examples
This expression for the Background.Color property
of a Salary column returns values that represent red when an employee’s
salary is greater than $70,000, green when an employee’s
salary is greater than $50,000, and blue otherwise:
1 |
<span>Case</span>(salary WHEN IS >70000 THEN RGB(255,0,0) WHEN IS<br>>50000 THEN RGB(0,255,0) ELSE RGB(0,0,255)) |
This expression for the Background.Color property
of an employee Id column returns red for Id 101, gray for Id 102,
and black for all other Id numbers:
1 |
<span>Case</span>(emp_id WHEN 101 THEN 255 WHEN 102 THEN<br>RGB(100,100,100) ELSE 0) |
This expression for the Format property of the Marital_status
column returns Single, Married, and Unknown based on the data value
of the Marital_status column for an employee:
1 |
<span>Case</span>(marital_status WHEN 'S'THEN 'Single' WHEN 'M' THEN<br>'Married' ELSE 'Unknown') |