Reference > Functions reference > Logical functions > Case
 

Case

Returns one of several possible results based on a series of tests.

Format 

Case ( test1 ; result1 {; test2 ; result2 ; ... ; defaultResult } )

Parameters 

test - any text or numeric expression.

result - result corresponding to the expression.

Parameters in braces { } are optional.

Data type returned 

text, number, date, time, timestamp, container

Originated in 

FileMaker Pro 6.0 or earlier

Description 

The Case function evaluates each test expression in order, and when a True expression is found, returns the value specified in result for that expression.

You can include a default result at the end of the parameter list. If none of the expressions evaluated return True, the Case function returns the value specified for defaultResult. If no default result is supplied, Case returns an empty result.

Example 1 

Case ( Score >= 90 ; "Excellent" ; Score > 50 ; "Satisfactory" ; "Needs Improvement" ) displays Excellent when the score is 90 or above, Satisfactory when the score is between 50 and 90, and Needs Improvement for any other score.

Example 2 

Case ( Shipment Method="Ground" ; 2 ; Shipment Method="Air" ; 10) returns 2 when the Shipment Method field contains Ground, and returns 10 when the Shipment Method field contains Air.

Related topics 

Functions reference (category list)

Functions reference (alphabetical list)

About formulas

About functions

Defining calculation fields

Using operators in formulas