Evaluates a list of conditions and returns one of multiple result expressions. Chose a value from a list of key value pairs.


object CASE(object key, param KVAL[] values)
object CASE(object key, object elseVal, params KVAL[] args)


CASE(CategoryID, KV(1,"One"), KV(2,"Two"), KV(3,"Three"))

Will return "One" when the CategoryID is equal to 1, "Two" when it is equal to 2 and "Three" when it is equal to three.


CASE(Product, WHEN("D", "Data Sync"), WHEN("O","Ouvvi"), WHEN("S","Server Edition"))

Will return "Data Sync" when the Product is D, "Ouvvi" when the product is O, and "Sever Edition" when the product is S.


Convert the salutation for Doctor into a small set of choices.

CASE(Salutation,Salutation // Default if no values found
	WHEN("Doctor", "Dr.")
	WHEN("Dr", "Dr.")
	WHEN("MD", "Dr."))


This function can be used to return boolean expressions as well, for example:

CASE(InvoiceStatus,WHEN("Paid", true), WHEN("Outstanding", false)

This will return true for any paid invoices and false for and outstanding invoices due payment.


Setting a default value to be returned if not found:

CASE(ProductCategory, "Misc", WHEN("S", "Software"), WHEN("H","Hardware"))

Which will return "Misc" if the ProductCategory is not "S" or "H", or it will return "Software" when the ProductCategory is S and "Hardware" when it is H.