> 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.

# FirstNonNull

> Use the Sigma FirstNonNull function to return the first non-null value in a column or grouping.

Returns the first non-null value in a column or grouping.

**FirstNonNull**() can be used as either an aggregate function or a window function. When used as a window function, it repeats the first non-null value for every row in the column.

This is similar to the [First](/docs/first)() function, but excludes null values.

## Syntax

`FirstNonNull(value)`

## Arguments

Function arguments:

|           |                                                                                                                                 |
| :-------- | :------------------------------------------------------------------------------------------------------------------------------ |
| **value** | A column to reference or a formula to calculate. The first non-null value is derived from input. All column types are accepted. |

## Notes

Consider data sort order when using this function:

* All sorting and/or filtering is applied prior to calculating this function.
* If no sort order is explicitly set, Sigma doesn't force one. In this case, sort order is determined by your Cloud Data Warehouse.

## Examples

### Example 1

This example shows the most recent non-null date from the `[Delivery Date]` column for each grouping under the `[Order Number]` column.

`FirstNonNull([Delivery Date])`

![](https://files.buildwithfern.com/sigma.docs.buildwithfern.com/6bdb0de7e6cfd734b38eb6746aec016842de2b923bcd613a4b6c25bfa1d85832/assets/docs-images/cda74c2-e1.png)

`[Delivery Date]` is sorted descending. If instead, `[Delivery Date]` was sorted ascending, the function would return the least recent non-null date for each grouping.

### Example 2

This example is similar to [Example 1](/docs/firstnonnull#example-1), but instead of using `FirstNonNull()` as an aggregate function, it is used as a window function. This means the calculation references a column in the same group, instead of referencing a column in a lower group. As a result the first non-null value is returned for every row.

The resulting calculations are dependent on the group’s sort order. In this example, the group of columns in which `FirstNonNull()` is calculated is sorted by the `[Product Family]` column. This sort order impacts the order of the `[Delivery Date]` column, which is then passed to `FirstNonNull()` in the `[Calc]` column.

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

## Related resources

* [First](/docs/first)
* [LastNonNull](/docs/lastnonnull)