> For the complete documentation index, see [llms.txt](https://docs.wem.io/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wem.io/platform/wemreference/keywords/logic/choose.md).

# Choose

{% hint style="info" %}
The `choose` construction can be used to check a multitude of conditions and return the expression that is part of the first condition that evaluates to be true.

The full construction should be created as displayed in the syntax, starting with <mark style="color:blue;">`choose`</mark>, ending with a <mark style="color:blue;">`default`</mark> expression and the <mark style="color:blue;">`end`</mark> keyword, and having 1 or more <mark style="color:blue;">`when ... then ...`</mark> expressions in between.

The Choose construct in WEM is comparable to Case or Switch statements in some programming languages. [See wikipedia](https://en.wikipedia.org/wiki/Conditional_\(computer_programming\)#Case_and_switch_statements).

This function is SQL compatible. For more information about SQL compatibility, see our [documentation](/platform/wemreference/sql-compatibility.md).
{% endhint %}

{% hint style="success" %}
Returns the value after the `then` of the **first** condition that returns true.

If all conditions return false, then the value after `default` is returned.&#x20;

Don't forget the `end` keyword.
{% endhint %}

{% hint style="warning" %}
All values after each then and default keyword must be of the same type to be returned.
{% endhint %}

<details>

<summary>Syntax</summary>

```
/*basic syntax : */
choose
    when boolean_condition1 then value1
    when boolean_condition2 then value2
    when boolean_condition3 then value3
    when boolean_condition4 then value4
    when boolean_condition5 then value5
    default value
end

/*Example: */
choose
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 1 Then "Monday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 2 Then "Tuesday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 3 Then "Wednesday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 4 Then "Thursday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 5 Then "Friday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 6 Then "Saturday"
    when DayOfWeek ([Webshop.Orders.OrderDate]) = 7 Then "Sunday"
    default "Day of the week"
end
```

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.wem.io/platform/wemreference/keywords/logic/choose.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
