---
title: "if function in Strata | Oplema"
description: "Choose between two values using a condition, as a shorter form of a two-way CASE expression. For example, if(2 > 1, 'yes', 'no') returns 'yes'."
url: "https://oplema.com/docs/strata/functions/if"
updated: "2026-11-04"
---

# if

Choose between two values using a condition.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **VARCHAR**.

### Expression

```
if(2 > 1, 'yes', 'no')
```

### Result

```
'yes'
```

To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | yes |

## Arguments and types

```
if(a, b, c)
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

### A missing condition

```
if(NULL::BOOLEAN, 'yes', 'no')
```

'no'

## Related functions

[CASE

Choose a result using one or more conditions.

](https://oplema.com/docs/strata/functions/case)[coalesce

Replace missing values with the first available alternative.

](https://oplema.com/docs/strata/functions/coalesce)[IS NULL

Find missing values without confusing them with empty text.

](https://oplema.com/docs/strata/functions/is-null)[Operators

Calculate values and combine comparisons in expressions.

](https://oplema.com/docs/strata/functions/operators)

[Browse conditions & missing values](https://oplema.com/docs/strata/functions#conditions-&-missing-values) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/utility.html#ifa-b-c)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
