> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://help.sigmacomputing.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://help.sigmacomputing.com/_mcp/server.

# LastNonNull

> Use the Sigma LastNotNull function to return the last non-Null value in a column or grouping.

The **LastNotNull** function returns the last non-Null value in a column or grouping.

**LastNonNull** is either an aggregate function, or a window function. As a window function, it repeats the last non-Null value for every row in the column.

This is similar to the [Last](/docs/last) function, but excludes Null values.

Data sort order is important when using this function: Sigma applies sorting and filtering before the function. Your CDW determines the default sort order.

## Syntax

```
LastNonNull([Column])
```

The function has the following argument:

<dl>
  <dt>
    Column
  </dt>

  <dd>
    The column input
  </dd>

  <dd>
    Accepts all data types
  </dd>
</dl>

## Examples

### Window function example

```
LastNonNull([Delivery Date])
```

Here the calculation references a column in a lower grouping level. This example shows the oldest non-null date from the **Delivery Date** column for each grouping under the **Order Number** column.

**Delivery Date** is in descending order sort. If **Delivery Date** is in ascending sort, the function returns the most recent non-Null date for each grouping.

![](https://fdr-prod-docs-files-public.s3.us-east-1.amazonaws.com/sigma.docs.buildwithfern.com/281bf10a46b3cee37a6f6ef3e5798a3e427d2a84235bf08ceeac4a4c35f10fa9/assets/docs-images/45fbc2f-LastNonNullExample1.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIA6KXJSKKNFOCF7G4B%2F20260725%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20260725T122833Z&X-Amz-Expires=604800&X-Amz-Signature=6ff87e29f4a56b851a46f6f7724f2cf4319c25e2dfa6a169216a5d45e4dc1db1&X-Amz-SignedHeaders=host&x-amz-checksum-mode=ENABLED&x-id=GetObject)

### Aggregate function example

```
LastNonNull([Delivery Date])
```

Here the calculation references a column in the same grouping level, so the first non-Null value  returns for every row.

Note how the resulting calculations depend on the group’s sort order. The sort on the **Product Family** affects the order of the **Delivery Date** column.

![](https://sigma-docs-screenshots.s3.us-west-2.amazonaws.com/Functions/lastnonnullexample+%232.png)

## Related resources

* [Last](/docs/last)
* [FirstNonNull](/docs/firstnonnull)