Imputing missing values replaces blanks with a substitute value: a default, an average, the last known value, or a value estimated from its neighbors. Interpolation is one kind of imputation, used for ordered data such as daily readings, where a missing point can be estimated from the points on either side.
Why it matters when importing data
Gaps break calculations and charts, but a wrong substitute is worse than a gap, because it looks like real data. The method has to match what the field means: a default for settings, forward fill for values that persist until they change, and interpolation for measurements that change smoothly.
Imputing Missing Values in JavaScript
Here are three common methods side by side on a series with gaps. Note that the mean ignores the trend, forward fill holds values flat, and linear interpolation follows the line between known points:
// Daily readings with gaps. Three common ways to fill them, and the original for comparison.
const readings = [
{ date: "2026-03-01", value: 10 },
{ date: "2026-03-02", value: null },
{ date: "2026-03-03", value: null },
{ date: "2026-03-04", value: 16 },
{ date: "2026-03-05", value: null },
{ date: "2026-03-06", value: 20 },
];
const known = readings.filter((r) => r.value !== null).map((r) => r.value);
const mean = known.reduce((sum, v) => sum + v, 0) / known.length;
// Forward fill: repeat the last known value.
let last = null;
const forwardFill = readings.map((r) =>
r.value !== null ? (last = r.value) : last
);
// Linear interpolation: draw a straight line between the known values on either side.
const linear = readings.map((r, i) => {
if (r.value !== null) return r.value;
let before = i - 1;
while (before >= 0 && readings[before].value === null) before--;
let after = i + 1;
while (after < readings.length && readings[after].value === null) after++;
if (before < 0 || after >= readings.length) return null; // cannot interpolate at the edges
const share = (i - before) / (after - before);
return (
readings[before].value +
share * (readings[after].value - readings[before].value)
);
});
const results = readings.map((r, i) => ({
date: r.date,
original: r.value,
mean: r.value ?? Number(mean.toFixed(2)),
forwardFill: forwardFill[i],
linear: linear[i],
}));
console.table(results); Output
| Date | Original | Mean | Forward fill | Linear |
|---|---|---|---|---|
| 2026-03-01 | 10 | 10 | 10 | 10 |
| 2026-03-02 | null | 15.33 | 10 | 12 |
| 2026-03-03 | null | 15.33 | 10 | 14 |
| 2026-03-04 | 16 | 16 | 16 | 16 |
| 2026-03-05 | null | 15.33 | 16 | 18 |
| 2026-03-06 | 20 | 20 | 20 | 20 |
Edge cases to handle
- Do not impute identifiers or required facts. A missing email or tax ID must be flagged, not invented.
- Edges. Interpolation needs a known value on both sides, so leading and trailing gaps stay empty, or fall back to forward fill.
- Mark imputed values. Keep a flag so reports can tell real values from estimates.
- Defaults are imputation too. Filling a blank country with
United Statesis a decision. Make it visible to the user.
How Dromo handles imputing missing values
In Dromo, a row hook can fill a default or compute a value from other fields in the row, and attach an info message so the user can see it was filled in. With enableUserTransformations turned on, users can describe a fill in plain language in the review step, such as filling blank country cells with United States, and review the change before submitting.
Related terms
- Requiring Values: Making sure required fields contain a real value.
- Flagging Invalid Rows: Marking rows that fail validation so they can be fixed, not deleted.
- Standardizing Date Formats: Converting dates written in different formats into one consistent format.
Frequently asked questions
What does imputing missing values mean?
Imputing means replacing missing values with substitutes, such as a default, the column average, the previous value, or an estimate from neighboring values, so that the dataset is complete enough to use.
What is the difference between imputation and interpolation?
Interpolation is a type of imputation for ordered data that estimates a missing value from the known values before and after it. Imputation also includes methods that ignore order, such as filling with the mean or a default.