# $cond

`$cond` operator lets you build conditions directly in CQL and returns you the item based on the condition passed in the object. You can use this in any [<mark style="color:blue;">**Expression Object**</mark>](/flow-builder/cql-cosmocloud-query-language/building-expressions.md).

## Syntax

```json
{
    "$cond": [ <condition>, <true_val>, <false_val> ]
}
```

### Properties

| Field         | Description                                                                                                                                                                                                                                                        | Required |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |
| \<condition>  | <p>The <code>\<condition></code> can be any valid <a href="/pages/aJtci0lt5gcR4VOrIDr9"><mark style="color:blue;"><strong>condition object</strong></mark></a> as long as it resolves to a boolean object.</p><p></p><p>It can also be a Magical Autocomplete.</p> | true     |
| \<true\_val>  | <p>The value to return if the <code>\<condition></code> resolves to <code>true</code>. <br><br>It can also be a Magical Autocomplete.</p>                                                                                                                          | true     |
| \<false\_val> | <p>The value to return if the <code>\<condition></code> resolves to <code>false</code>. <br><br>It can also be a Magical Autocomplete.</p>                                                                                                                         | true     |

### Returns

`<object>` - Returns either the `<true_val>` or `<false_val>` based on the condition. The object type can be anything based on the values provided.

## Examples

### With Magical Autocomplete

Let's say we have declared a variable `country` in our API flow, which has an array value of `US` currently.

```json
{
    "$cond": [ 
        { "$eq": ["$.variables.country", "India"] },
        10,
        20
    ]
}
```

The above expression returns **20** as the condition becomes false.


---

# 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.cosmocloud.io/flow-builder/cql-cosmocloud-query-language/building-expressions/usdcond.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.
