# FILLMISSING_LAST
URL: https://docs.valsight.ai/fillmissing-last/
Description: The FILLMISSING_LAST function fills missing level values in a node by carrying forward the last observed value from a specified dimension, with a fallback constant value before the first data point.
**Category:** [Filtering & data shaping](/filtering-data-shaping/)

## Overview

The **FILLMISSING\_LAST** function **fills missing level values using the last available value from a specified dimension in the input node.**
If a row does not have a previous value, the Value parameter is used as fallback. The input node must already contain the levels of the dimension. If no dimension is specified, the default dimension is `"Time"`.

Use this function when you want to fill structurally missing level values with the last available value instead of a constant.

## Syntax

`FILLMISSING_LAST('Node' [, "Dimension" [, Value [, "Behavior"]]])`

**Example usage:** `FILLMISSING_LAST('Revenue')`

## Parameters

| Parameter     | Description                                                                                                                         | Type           | Required | Default           |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------------- | -------- | ----------------- |
| **Node**      | Input node with potentially missing level values, specified in single quotes (e.g.`'Revenue'`)                                      | Node reference | Yes      | --                |
| **Dimension** | Name of the dimension whose level values will be used to fill the input node, specified in double quotes (e.g.`"ProductDimension"`) | Dimension name | No       | Finest time level |
| **Value**     | Fallback value used when there is no last available value (i.e. before the first data point)                                        | Number         | No       | `0`               |
| **Behavior**  | Controls which missing entries are filled. Available values: `"All"`, `"StartAtFirst"`, `"FinishAtLast"`, `"Interval"`              | Keyword        | No       | `"All"`           |

**Behavior options:**

* `"All"`: Fills all missing values. Before the first data point, the fallback Value is used. After the first data point, the last observed value is carried forward.
* `"StartAtFirst"`: Starts filling from the first data point onward. No rows are generated before the first value.
* `"FinishAtLast"`: Fills from the start of the horizon up to (and including) the last data point. No rows are generated after the last value.
* `"Interval"`: Fills only between the first and last data points. No rows before first or after last.

## Output shape

| Aspect         | Behavior                                                                                                                      |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| Dimensionality | Unchanged (no levels added or removed)                                                                                        |
| Values         | Existing rows preserved. New rows are filled with the last observed value, or the fallback Value before the first data point. |
| Row count      | Increases to include filled missing level values (extent depends on Behavior)                                                 |

## Watch out

* The input node must already **contain levels** of the specified dimension. FILLMISSING\_LAST does not add new levels to the node.
* The Value parameter is only used as a **fallback before the first observed data point**. After the first value, forward-fill (last observed value) applies regardless of the Value parameter.
* If the node has **linked levels**, you cannot fill values of the linked-to dimension. Fill the source dimension instead to get all valid values.
* This function enforces level links from dimension management. **Do not use** this function if you want the node to have different level links than the dimensions.
* The fill operates **per partition**: with multiple non-target dimensions (e.g. products within years), the forward-fill runs independently for each partition.
* If the input is empty, the function falls back to [FILLMISSING](/fillmissing/) behavior (constant fill).

## Examples

### Fill missing values across the time horizon

This example fills missing year values using the last available value. The project time horizon is 2025-2029.

The input node features the level values `"2026"` and `"2028"`.

**Input node:** `'Input node'`

| Year | Value |
| ---- | ----- |
| 2026 | 10    |
| 2028 | 50    |

**Formula:** `FILLMISSING_LAST('Input node')`

| Year | FILLMISSING\_LAST Result |
| ---- | ------------------------ |
| 2025 | 0                        |
| 2026 | 10                       |
| 2027 | 10                       |
| 2028 | 50                       |
| 2029 | 50                       |

The value `10` from 2026 is carried forward to 2027. The value `50` from 2028 is carried forward to 2029. Before the first data point (2025), the default fallback value `0` is used.

**Formula:** `FILLMISSING_LAST('Input node', "Time", 0, "StartAtFirst")`

| Year | FILLMISSING\_LAST Result |
| ---- | ------------------------ |
| 2026 | 10                       |
| 2027 | 10                       |
| 2028 | 50                       |
| 2029 | 50                       |

`"StartAtFirst"` starts from the first available value (2026), so 2025 is omitted.

**Formula:** `FILLMISSING_LAST('Input node', "Time", 0, "FinishAtLast")`

| Year | FILLMISSING\_LAST Result |
| ---- | ------------------------ |
| 2025 | 0                        |
| 2026 | 10                       |
| 2027 | 10                       |
| 2028 | 50                       |

`"FinishAtLast"` fills until the last value (2028), so 2029 is omitted.

**Formula:** `FILLMISSING_LAST('Input node', "Time", 0, "Interval")`

| Year | FILLMISSING\_LAST Result |
| ---- | ------------------------ |
| 2026 | 10                       |
| 2027 | 10                       |
| 2028 | 50                       |

`"Interval"` fills only between the first (2026) and last (2028) present values.

### Fill missing values on a non-time dimension

This example fills missing product values by carrying the last available product value forward within each year.

The dimension `"ProductDimension"` consists of the level `"Product"` with values `"A"`, `"B"`, `"C"`, `"D"`, and `"E"`.

**Input node:** `'Input node'`

| Year | Product | Value |
| ---- | ------- | ----- |
| 2026 | B       | 10    |
| 2028 | C       | 50    |
| 2028 | E       | 100   |

**Formula:** `FILLMISSING_LAST('Input node', "ProductDimension")`

| Year | Product | FILLMISSING\_LAST Result |
| ---- | ------- | ------------------------ |
| 2026 | A       | 0                        |
| 2026 | B       | 10                       |
| 2026 | C       | 10                       |
| 2026 | D       | 10                       |
| 2026 | E       | 10                       |
| 2028 | A       | 0                        |
| 2028 | B       | 0                        |
| 2028 | C       | 50                       |
| 2028 | D       | 50                       |
| 2028 | E       | 100                      |

For 2026, the first available product is `"B"` with value `10`, which is carried forward to `"C"`, `"D"`, `"E"`. Products before `"B"` get the fallback value `0`. For 2028, the forward-fill runs independently: `"C"` = **50** carries to `"D"`, then `"E"` = **100** takes over.

**Formula:** `FILLMISSING_LAST('Input node', "ProductDimension", 0, "StartAtFirst")`

| Year | Product | FILLMISSING\_LAST Result |
| ---- | ------- | ------------------------ |
| 2026 | B       | 10                       |
| 2026 | C       | 10                       |
| 2026 | D       | 10                       |
| 2026 | E       | 10                       |
| 2028 | C       | 50                       |
| 2028 | D       | 50                       |
| 2028 | E       | 100                      |

`"StartAtFirst"` starts from the first available product in each year.

**Formula:** `FILLMISSING_LAST('Input node', "ProductDimension", 0, "FinishAtLast")`

| Year | Product | FILLMISSING\_LAST Result |
| ---- | ------- | ------------------------ |
| 2026 | A       | 0                        |
| 2026 | B       | 10                       |
| 2028 | A       | 0                        |
| 2028 | B       | 0                        |
| 2028 | C       | 50                       |
| 2028 | D       | 50                       |
| 2028 | E       | 100                      |

`"FinishAtLast"` stops at the last available product in each year.

**Formula:** `FILLMISSING_LAST('Input node', "ProductDimension", 0, "Interval")`

| Year | Product | FILLMISSING\_LAST Result |
| ---- | ------- | ------------------------ |
| 2026 | B       | 10                       |
| 2028 | C       | 50                       |
| 2028 | D       | 50                       |
| 2028 | E       | 100                      |

`"Interval"` fills between first and last. For 2026, there is only one value (`"B"`), so no interval to fill.

## Related

| Function                     | When to use instead                                                                                                                    |
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| [FILLMISSING](/fillmissing/) | When you want missing values filled with a constant instead of the last available value.                                               |
| [FILL\_NA](/fill-na/)        | When you want to fill N/A values on existing level combinations after pivoting instead of adding missing level values for a dimension. |
