# 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](https://docs.redivis.com/reference/workflows/step-filter#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: 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.
