fill
Estimate missing values using linear interpolation along an ordered sequence.
Try an expression
In Formula, enter the expression and set Output type to INTEGER.
Example input
- Row 1
id = 1, amount = 10 - Row 2
id = 2, amount = NULL - Row 3
id = 3, amount = 30 - Row 4
id = 4, amount = 30
Expression
fill(amount ORDER BY id) OVER ()Result
Row 1: 10
Row 2: 20
Row 3: 30
Row 4: 30NULL means the value is missing.
Arguments and types
fill(expr[ ORDER BY ordering])The result type can depend on the input types. See DuckDB for the full argument rules.
Things to know
ORDER BY defines the order used by the calculation; it doesn't sort the output table. Include a unique tie-breaker when row position matters. Window expressions belong in Formula and can't be entered directly in Filter.
Only one ordering key is supported. Missing values between known values are interpolated; values outside the known range are extrapolated.
Missing values at both ends
fill(CASE WHEN id IN (2,3) THEN id * 10 END ORDER BY id) OVER ()Row 1: 10 Row 2: 20 Row 3: 30 Row 4: 40
Function metadata from DuckDB, used under the MIT license.