> For the complete documentation index, see [llms.txt](https://docs.redivis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redivis.com/reference/workflows/transforms/variable-creation-methods/case-if-else.md).

# Case (if/else)

This common method utilizes if-then-else logic, assigning a result when the corresponding condition evaluates to true, otherwise assigning the final ("else") result –> [learn more](https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#case)

```sql
CASE
  WHEN @condition THEN @result
  [ ... ]
  [ ELSE @else_result ]
  END
```

#### Return type

dynamic (input-dependent)

#### Parameters

| Name           | Type                                                                                                                                                                           | Allowed values                                                                           | Required | Placeholder (in UI)   |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | -------- | --------------------- |
| `@condition`   | (nested) conditions – like those used in a [Filter](/reference/workflows/transforms/step-filter.md#step-structure)                                                             | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | -                     |
| `@result`      | [variable](https://docs.redivis.com/reference/projects/transforms/parameters#variable) or [literal](https://docs.redivis.com/reference/projects/transforms/parameters#literal) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | *(Variable or value)* |
| `@else_result` | [variable](https://docs.redivis.com/reference/projects/transforms/parameters#variable) or [literal](https://docs.redivis.com/reference/projects/transforms/parameters#literal) | any [Redivis type](https://docs.redivis.com/reference/datasets/variables#variable-types) | true     | *(Variable or value)* |


---

# 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:

```
GET https://docs.redivis.com/reference/workflows/transforms/variable-creation-methods/case-if-else.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
