switch, you can list a set of values that can be assigned to an expression. Which expression gets used as output, is determined by how you write the
The expression has to close with the keyword
This operator is most often used in calculated information.
switch [expression]when [value_1] then [expression_1]...when [value_n] then [expression_n]else [expression]end
All values will be compared against the result of the expression
All expressions need to return the same type of output, e.g. a number.
If none of the defined values apply, the expression following
else is used.
A Zurich-based institution is mostly active in its home market and in Germany. It groups its customers in three categories, based on where they live.
Swiss customers get labeled as local. German customers get the label German. The relatively small number of customers from other countries get grouped together in a ‘world’ category.
switch self.domicilewhen che then local_customerwhen deu then german_customerelse world_customerend
If the domicile of the instance is provided as Germany, the output will mark the instance as german_customer. Is the domicile South Africa, the
else is used: this instance is ‘world_customer’.