# Fill in missing values

Shape / columns

replace, coalesce, impute or flag missing values

Page: <https://meridian.online/operations/fill-in-missing-values>

## Status

Runs as a SQL step.

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

## The DuckDB step

impute with the column mean and flag it

It reads the `orders` table the proofs share. Create it first:

```sql
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);
```

Then run the statement:

```sql
CREATE TEMP TABLE result AS
SELECT order_id, amount IS NULL AS was_missing, coalesce(amount, round(avg(amount) OVER (), 2)) AS amount_filled FROM orders;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT count(*) FILTER (WHERE was_missing) = 1 AND max(amount_filled) FILTER (WHERE was_missing) = 211.19 FROM result)) THEN 'as expected' ELSE error('the missing amount was not filled with the mean, 211.19') END AS verdict;
```

It needs nothing installed beyond DuckDB itself.

## Variants

- [Take the first value that is present](https://meridian.online/operations/fill-in-missing-values/take-the-first-present-value): Return, row by row, the first non-null value across several columns.
- Replace missing values with a set value: Put a chosen literal in place of each null or NaN.
- [Flag missing values](https://meridian.online/operations/fill-in-missing-values/flag-missing-values): Add a column that marks whether each value is missing, leaving the value alone.
- Fill from neighbouring values: Carry the last present value forward, or interpolate between the values either side.
- Predict missing values with a model: Fill missing values with predictions from a model trained on the other columns.
- [Turn values into nulls](https://meridian.online/operations/fill-in-missing-values/turn-values-into-nulls): Mark a given value, or the selected cells, as missing.
- [Fill with the mean, median or mode](https://meridian.online/operations/fill-in-missing-values/fill-with-a-column-statistic): Replace missing values with a statistic of the column, such as its mean, median or mode.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

- Alteryx Designer: [`Imputation`](https://help.alteryx.com/current/en/designer/tools/preparation/imputation-tool.html) (read 2026-09-27)
- Apache DataFusion: [`Conditional Functions`](https://datafusion.apache.org/user-guide/sql/scalar_functions.html) (read 2026-09-27)
- Apache DataFusion: [`fill_nan`](https://docs.rs/datafusion/latest/datafusion/dataframe/struct.DataFrame.html) (read 2026-09-27)
- Apache DataFusion: [`fill_null`](https://docs.rs/datafusion/latest/datafusion/dataframe/struct.DataFrame.html) (read 2026-09-27)
- Duckle: [`Coalesce / Null Fill`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Constant Fill`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- EasyMorph: [`Fill right`](https://help.easymorph.com/doku.php?id=transformations:fillright) (read 2026-09-27)
- AWS Glue: [`FillMissingValues`](https://docs.aws.amazon.com/glue/latest/dg/transforms-configure-fmv.html) (read 2026-09-27)
- AWS Glue: [`FillMissingValues`](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-transforms-fillmissingvalues.html) (read 2026-09-27)
- AWS Glue: [`FillWithMode`](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-pyspark-transforms-FillWithMode.html) (read 2026-09-27)
- Apache Hop: [`Coalesce`](https://hop.apache.org/manual/latest/pipeline/transforms/coalesce.html) (read 2026-09-27)
- Apache Hop: [`If null`](https://hop.apache.org/manual/latest/pipeline/transforms/ifnull.html) (read 2026-09-27)
- Apache Hop: [`Null If`](https://hop.apache.org/manual/latest/pipeline/transforms/nullif.html) (read 2026-09-27)
- Ibis: [`Coalesce`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/generic.py) (read 2026-09-27)
- Ibis: [`FillNull`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/relations.py) (read 2026-09-27)
- Ibis: [`IsNull`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/generic.py) (read 2026-09-27)
- Ibis: [`NotNull`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/generic.py) (read 2026-09-27)
- Ibis: [`NullIf`](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)
- KNIME Analytics Platform: [`Extract Missing Value Cause`](https://api.hub.knime.com/nodes/*WfViBjs3J9W6KB5x?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Missing Value`](https://api.hub.knime.com/nodes/*uVmaGQkzUOFCTqUe?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Missing Value (Apply)`](https://api.hub.knime.com/nodes/*MtI-i19EnG7ZKJC7?details=full) (read 2026-09-27)
- mlpack: [`Imputation`](https://www.mlpack.org/doc/user/preprocessing.html) (read 2026-09-27)
- OpenRefine: [`Facet by blank (null or empty string)`](https://openrefine.org/docs/manual/facets#facet-by-null-empty-or-blank) (read 2026-09-27)
- OpenRefine: [`Facet by empty string`](https://openrefine.org/docs/manual/facets#facet-by-null-empty-or-blank) (read 2026-09-27)
- OpenRefine: [`Facet by null`](https://openrefine.org/docs/manual/facets#facet-by-null-empty-or-blank) (read 2026-09-27)
- OpenRefine: [`To empty string`](https://openrefine.org/docs/manual/cellediting#data-type-transforms) (read 2026-09-27)
- OpenRefine: [`To null`](https://openrefine.org/docs/manual/cellediting#data-type-transforms) (read 2026-09-27)
- Pentaho Data Integration: [`If field value is null`](https://docs.pentaho.com/pdia-data-integration/9.3-data-integration/pdi-transformation-steps-reference-overview) (read 2026-09-27)
- Pentaho Data Integration: [`Null if...`](https://docs.pentaho.com/pdia-data-integration/9.3-data-integration/pdi-transformation-steps-reference-overview) (read 2026-09-27)
- Polars: [`DataFrame.fill_nan`](https://docs.pola.rs/api/python/stable/reference/dataframe/modify_select.html) (read 2026-09-27)
- Polars: [`DataFrame.fill_null`](https://docs.pola.rs/api/python/stable/reference/dataframe/modify_select.html) (read 2026-09-27)
- Polars: [`DataFrame.interpolate`](https://docs.pola.rs/api/python/stable/reference/dataframe/modify_select.html) (read 2026-09-27)
- Polars: [`Expr.fill_nan`](https://docs.pola.rs/api/python/stable/reference/expressions/modify_select.html) (read 2026-09-27)
- Polars: [`Expr.fill_null`](https://docs.pola.rs/api/python/stable/reference/expressions/modify_select.html) (read 2026-09-27)
- Polars: [`Expr.interpolate`](https://docs.pola.rs/api/python/stable/reference/expressions/modify_select.html) (read 2026-09-27)
- Polars: [`Expr.interpolate_by`](https://docs.pola.rs/api/python/stable/reference/expressions/modify_select.html) (read 2026-09-27)
- Polars: [`coalesce`](https://docs.pola.rs/api/python/stable/reference/expressions/functions.html) (read 2026-09-27)
- RapidMiner Studio: [`Declare Missing Value`](https://docs.rapidminer.com/latest/studio/operators/cleansing/missing/declare_missing_value.html) (read 2026-09-27)
- RapidMiner Studio: [`Declare Missing Value (In Database)`](https://docs.rapidminer.com/latest/studio/operators/extensions/In-Database%20Processing/indb_cleansing/indb_declare_missing.html) (read 2026-09-27)
- RapidMiner Studio: [`Impute Missing Values`](https://docs.rapidminer.com/latest/studio/operators/cleansing/missing/impute_missing_values.html) (read 2026-09-27)
- RapidMiner Studio: [`Replace All Missings`](https://docs.rapidminer.com/latest/studio/operators/cleansing/missing/universal_missing_value_handling.html) (read 2026-09-27)
- RapidMiner Studio: [`Replace Missing Values`](https://docs.rapidminer.com/latest/studio/operators/cleansing/missing/replace_missing_values.html) (read 2026-09-27)
- RapidMiner Studio: [`Replace Missing Values (In Database)`](https://docs.rapidminer.com/latest/studio/operators/extensions/In-Database%20Processing/indb_cleansing/indb_replace_missing.html) (read 2026-09-27)
- Tableau Prep: [`Merge Fields`](https://help.tableau.com/current/prep/en-us/prep_clean.htm) (read 2026-09-27)
- Trifacta: [`Replace missing`](https://help.alteryx.com/aac/en/trifacta-classic/reference/transformation-reference.html) (read 2026-09-27)
- VisiData: [`delete-cell`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/clipboard.py#L207) (read 2026-09-23)
- VisiData: [`delete-cells`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/clipboard.py#L208) (read 2026-09-23)
