---
title: "union_tag function in Strata | Oplema"
description: "Get the tag currently selected in a union, returned as an ENUM. Write it as union_tag(union) in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/union-tag"
updated: "2026-11-04"
---

# union\_tag

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

## Try an expression

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

### Expression

```
union_tag(union_value(k := 'foo'))
```

### Result

```
'k'
```

The expression returns `ENUM('k')`. Formula stores it as `VARCHAR` in this example. 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 | k |

## Arguments and types

```
union_tag(union)
```

**union**

Union

Supported signatures (1)

```
union_tag(union: UNION) → ANY
```

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

## Related functions

[union\_extract

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

](https://oplema.com/docs/strata/functions/union-extract)[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_tagunion)

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