---
title: "last_value window function in Strata | Oplema"
description: "Return the last value of a window frame on every row, such as a group's closing figure. Use it in a Strata Formula with an OVER clause."
url: "https://oplema.com/docs/strata/functions/last-value"
updated: "2026-11-04"
---

# last\_value

Repeat the last value in a window frame.

## Try an expression

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

Example input

1. Row 1 `id = 1, amount = 10`
2. Row 2 `id = 2, amount = NULL`
3. Row 3 `id = 3, amount = 30`
4. Row 4 `id = 4, amount = 30`

### Expression

```
last_value(amount) OVER (ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
```

### Result

```
Row 1: 30
Row 2: 30
Row 3: 30
Row 4: 30
```

NULL means the value is missing.

Try it live in Formula

Result
| id | amount | result |
| --- | --- | --- |
| 1 | 10 | 30 |
| 2 |  | 30 |
| 3 | 30 | 30 |
| 4 | 30 | 30 |

## Arguments and types

```
last_value(expr[ ORDER BY ordering][ IGNORE NULLS])
```

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

## Things to know

ORDER BY defines the order used by the calculation; it doesn't sort the output table. Include a unique tie-breaker when row position matters. Window expressions belong in Formula and can't be entered directly in Filter.

This example explicitly includes the whole partition in its frame. Without that frame, the last value can be the current row instead.

## Related functions

[first\_value

Repeat the first value in a window frame.

](https://oplema.com/docs/strata/functions/first-value)[nth\_value

Retrieve a value at a specified position within a window frame.

](https://oplema.com/docs/strata/functions/nth-value)[cume\_dist

Find the fraction of rows whose sort value is less than or equal to the current value.

](https://oplema.com/docs/strata/functions/cume-dist)[lag

Compare each row with a value from an earlier row.

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

[Browse across rows](https://oplema.com/docs/strata/functions#across-rows) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/window_functions.html#last_valueexpr-order-by-ordering-ignore-nulls)

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