# Take the first value that is present

Shape / columns

A variant of [Fill in missing values](https://meridian.online/operations/fill-in-missing-values).

Return, row by row, the first non-null value across several columns.

Page: <https://meridian.online/operations/fill-in-missing-values/take-the-first-present-value>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

take the first non-null value across several columns

```sql
CREATE TEMP TABLE contacts AS SELECT * FROM (VALUES
  (1, 'mobile-1', 'home-1', 'work-1'), (2, NULL, 'home-2', NULL), (3, NULL, NULL, 'work-3'), (4, NULL, NULL, NULL), (5, '', 'home-5', NULL)
) t(id, mobile, home, work);
CREATE TEMP TABLE result AS
SELECT id, coalesce(mobile, home, work) AS phone, coalesce(mobile, home, work, 'none') AS phone_or_none FROM contacts;
SELECT * FROM result ORDER BY id;
SELECT CASE WHEN ((SELECT list(phone ORDER BY id) FROM result) = ['mobile-1', 'home-2', 'work-3', NULL, ''] AND (SELECT list(phone_or_none ORDER BY id) FROM result) = ['mobile-1', 'home-2', 'work-3', 'none', '']) THEN 'as expected' ELSE error('the first non-null phone was not taken row by row, or an all-null row did not stay null, or an empty string was skipped') END AS verdict;
```

The statement builds its own data.

It needs nothing installed beyond DuckDB itself.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

- Apache DataFusion: [`Conditional Functions`](https://datafusion.apache.org/user-guide/sql/scalar_functions.html) (read 2026-09-27)
- Duckle: [`Coalesce / Null Fill`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Apache Hop: [`Coalesce`](https://hop.apache.org/manual/latest/pipeline/transforms/coalesce.html) (read 2026-09-27)
- Ibis: [`Coalesce`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/generic.py) (read 2026-09-27)
- KNIME Analytics Platform: [`Column Merger`](https://api.hub.knime.com/nodes/*O1vxA5XLe8KOPQHT?details=full) (read 2026-09-27)
- Polars: [`coalesce`](https://docs.pola.rs/api/python/stable/reference/expressions/functions.html) (read 2026-09-27)
- Tableau Prep: [`Merge Fields`](https://help.tableau.com/current/prep/en-us/prep_clean.htm) (read 2026-09-27)
