Notification

The AppSheet Help Center documentation can now be viewed in Japanese - AppSheet ヘルプセンターのドキュメントが日本語で表示できるようになりました。. Learn more

SWITCH()

Choose-one conditional evaluation

Returns the results of an expression corresponding to the first matching value when evaluating one value against a list of values, or the results of the default expression if there is no match.

Sample usage

SWITCH([Date],TODAY(),"Today",(TODAY() - 1),"Yesterday",(TODAY() + 1),"Tomorrow", TEXT([Date])) returns a user-friendly date string, such as Today, Yesterday, or Tomorrow.

SWITCH([Color], "Red", 3, "Yellow", 2, "Green", 1, 0) returns a numeric value based on the color value.

SWITCH([Access Required], "Admin", IN(USEREMAIL(), Admin Users[Email]), "User", IN(USEREMAIL(), Users[Email]), FALSE) returns the role required for access.

SWITCH(CONTEXT("Host"), "Device", "Tap below to:", "Browser", "Click below to:", "") returns different directions depending on whether the app is running from the native app on a device or from a browser. This might be used to generate a display name for a gallery view of launchers. See also: CONTEXT()

Syntax

SWITCH(expression, case1, value1, [case2, value2 ...], default)

  • expression - Value or expression of any type.
  • case1 - First condition to be checked against value. Must be comparable type to value.
  • value1 - Expression that is evaluated and returned if case1 is a match.
  • case2, value2 … (Optional) Additional conditions and expressions if the first one doesn’t match the expression.
  • default - An expression that is evaluated and returned if no match is found.
Note: Every result expression should produce a value of the same type.

 

Was this helpful?

How can we improve it?

Need more help?

Try these next steps:

true
Search
Clear search
Close search
Main menu
3769918694573697108
true
Search Help Center
true
true
true
false
false