case()

Read(366) 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 right. Compute the conditional expression x first, and then xk. If there is any expression xk that satisfies the result of x, return the result of yk and stop 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

=4

 

4

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

null

Related functions:

if()

between()