---
title: "constant_or_null function in Strata | Oplema"
description: "Return the first argument, unless a later argument is NULL, in which case return NULL. Use it in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/constant-or-null"
updated: "2026-11-04"
---

# constant\_or\_null

Return the first argument, or a missing value if the second argument is missing.

## Try an expression

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

### Expression

```
constant_or_null(42, 1)
```

### Result

```
42
```

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 | 42 |

## Arguments and types

```
constant_or_null(arg1, arg2, ...)
```

**arg1**

Any value

**arg2**

Any value

Supported signatures (1)

```
constant_or_null(arg1: ANY, arg2: ANY, ...: ANY) → ANY
```

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

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[CAST

Convert a value to another data type; invalid conversions raise an error.

](https://oplema.com/docs/strata/functions/cast)[nullif

Turn a sentinel value, such as zero or an empty string, into a missing value.

](https://oplema.com/docs/strata/functions/nullif)[gen\_random\_uuid

Return a random UUID v4, such as 7e7ea35f-f813-46ce-ac7b-12658c021bcb.

](https://oplema.com/docs/strata/functions/gen-random-uuid)[TRY\_CAST

Convert a value to another data type, returning a missing value if conversion fails.

](https://oplema.com/docs/strata/functions/try-cast)

[Browse conversion & identifiers](https://oplema.com/docs/strata/functions#conversion-&-identifiers) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/utility.html#constant_or_nullarg1-arg2)

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