---
updatedAt: 2025-12-05T18:41:41.000Z
agentTools:
  projectIndex: https://docs.observeinc.com/llms.txt
---

# last_not_null

```
last_not_null(value: storable, [order_by(...)]?) -> value
```

Return the last non-null value of one column across an ordered group.

If no ordering is specified, the default ordering is that of the invoking verb, which is generally the 'valid\_from' timestamp, ascending. In this case, the last value is the latest.

# Domain

This is an aggregate function (aggregates rows over a group in [aggregate verbs](verb#aggregate-verbs)).

This is a window function (calculates over a group of multiple input rows using [windowing](function-window)).

# Categories

* [Aggregate](function#aggregate-functions)
* [Window](function#window-functions)

# Examples

<OpalCodeBlock code={
`make_col last_value:window(last_not_null(value), group_by(kind))
`}/>

Find out the last non-null within each kind.

<OpalCodeBlock code={
`statsby last_customer:last_not_null(customer_id), group_by(category)
`}/>

Find out the last non-null customer within each category.

<OpalCodeBlock code={
`statsby last_customer:last_not_null(customer_id, order_by(login_time)), group_by(category)
`}/>

Find out the non-null customer that logged in last within each category.