---
title: "union_extract function in Strata | Oplema"
description: "Get a union's value for the tag you name, or NULL when another tag is selected. For example, union_extract(union_value(k := 'hello'), 'k') returns 'hello'."
url: "https://oplema.com/docs/strata/functions/union-extract"
updated: "2026-11-04"
---

# union\_extract

Extract the value with the named tags from the union. NULL if the tag isn't currently selected.

## Try an expression

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

### Expression

```
union_extract(union_value(k := 'hello'), 'k')
```

### Result

```
'hello'
```

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

## Arguments and types

```
union_extract(union, tag)
```

**union**

Union

**tag**

Text

Supported signatures (1)

```
union_extract(union: UNION, tag: VARCHAR) → ANY
```

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

## Related functions

[union\_tag

Retrieve the currently selected tag of the union as an ENUM.

](https://oplema.com/docs/strata/functions/union-tag)[union\_value

Create a union with one member. The tag comes from the name of the argument, as in union\_value(k := 1).

](https://oplema.com/docs/strata/functions/union-value)

[Browse unions](https://oplema.com/docs/strata/functions#unions) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/union.html#union_extractunion-tag)

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