series_fill_backward
This page explains how to use the series_fill_backward function in APL.
The series_fill_backward function fills missing values (nulls) in a numeric dynamic array (series) by propagating the last known value backward through the array. This function is useful for handling gaps in time series data where you want to use the most recent available value to fill earlier missing data points.
You can use series_fill_backward when you have time series data with missing values and want to fill gaps using the last observed value. This is particularly useful for forward-looking analysis, forecasting scenarios, or when the most recent data point is the best estimate for missing earlier values. Typical applications include financial data analysis, sensor data processing, and performance monitoring where recent values are more relevant.
Usage
Syntax
Parameters
| Parameter | Type | Description |
|---|---|---|
array | dynamic | A dynamic array of numeric values that may contain null values. |
Returns
A dynamic array where null values are replaced by the last non-null value encountered when traversing the array backward.
Use case examples
In log analysis, you can use series_fill_backward to fill missing request duration data using the most recent available values, which is useful for analyzing performance trends.
Query
Output
| id | durations | filled_durations |
|---|---|---|
| u123 | [null, 150, null, 200] | [150, 150, 150, 200] |
| u456 | [100, null, null, 300] | [100, 300, 300, 300] |
This query fills missing request durations with the most recent available values, useful for maintaining continuity in performance analysis.
In OpenTelemetry traces, you can use series_fill_backward to fill missing span duration data using the most recent observed values for better trace analysis.
Query
Output
| service.name | durations | filled_durations |
|---|---|---|
| frontend | [null, 100ms, null, 200ms] | [100ms, 100ms, 100ms, 200ms] |
| productcatalogservice | [50ms, null, null, 150ms] | [50ms, 150ms, 150ms, 150ms] |
This query fills missing span durations with the most recent available values, useful for maintaining continuity in service performance analysis.
In security logs, you can use series_fill_backward to fill missing request duration data using the most recent values for consistent security analysis.
Query
Output
| status | durations | filled_durations |
|---|---|---|
| 200 | [null, 150, null, 250] | [150, 150, 150, 250] |
| 500 | [100, null, null, 400] | [100, 400, 400, 400] |
This query fills missing request durations with the most recent available values grouped by status code, useful for consistent security analysis across different response types.
List of related functions
- series_fill_forward: Fills missing values by propagating the first known value forward. Use when you want to use the earliest available value to fill gaps.
- series_fill_const: Fills missing values with a constant value. Use when you want to replace nulls with a specific default value.
- series_fill_linear: Fills missing values using linear interpolation. Use when you want smooth transitions between known values.
- series_equals: Compares each element to a specified value. Use for identifying specific values after filling operations.
- series_greater: Returns elements greater than a specified value. Use for threshold analysis after filling missing data.