case()

Read(282) Label: return result, return null,

Description:

Return the value of the expression that satisfies the specified condition.

Syntax:

case(x,x1:y1,…,xk:yk;y)

Note:

This function computes from left to the right. First compute the conditional expression x that comes first, and then compute the other xk. If there is any expression xk that satisfies the result of x, then return the result of yk and terminate the computation. If there is no eligible expression xk, but there exists a default expression y, then return the result of y, otherwise, return null.

Parameters:

x

Conditional expression

xk

Value expression

yk

Result expression

y

Default expression

Example:

 

A

 

1

=3

 

2

=case(A1,1:"Dept 1",2:"Dept 2",3:"Dept 3";"Admin Dept")

Dept 3

3

>A1=4

 

4

=case(A1,1:"Dept 1",2:"Dept 2",3:"Dept 3",4:;"Admin Dept")

null

Related functions:

if()

between()