---
title: "TRY_CAST in Strata | Oplema"
description: "Convert a value to another data type, returning a missing value if conversion fails. Write it as TRY_CAST(expr AS type) in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/try-cast"
updated: "2026-11-04"
---

# TRY\_CAST

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

## Try an expression

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

Example input

1. Row 1 `amount = '12.5'`
2. Row 2 `amount = 'unknown'`
3. Row 3 `amount = NULL`

### Expression

```
TRY_CAST(amount AS DOUBLE)
```

### Result

```
Row 1: 12.5
Row 2: NULL
Row 3: NULL
```

NULL means the value is missing.

Try it live in Formula

Result
| id | amount | result |
| --- | --- | --- |
| 1 | 12.5 | 12.5 |
| 2 | unknown |  |
| 3 |  |  |

## Arguments and types

```
TRY_CAST(expr AS type)
```

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

## Related functions

[CAST

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

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

Return the name of an expression's data type.

](https://oplema.com/docs/strata/functions/typeof)[try\_strptime

Parse text into a timestamp using a format string such as %d/%m/%Y. Text that doesn't match returns a missing value instead of an error.

](https://oplema.com/docs/strata/functions/try-strptime)[coalesce

Replace missing values with the first available alternative.

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

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

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