Skip to main content

STL_Trend - chart function

STL_Trend is a time series decomposition function. Along with STL_Seasonal and STL_Residual, this function is used to decompose a time series into seasonal, trend, and residual components. In the context of the STL algorithm, time series decomposition is used to identify both a recurring seasonal pattern and a general trend, given an input metric and other parameters. The STL_Trend function will identify a general trend, independent of seasonal patterns or cycles, from time series data.

The three STL functions are related to the input metric through a simple sum:

STL_Trend + STL_Seasonal + STL_Residual = Input metric

STL (seasonal and trend decomposition using Loess) employs data smoothing techniques, and through its input parameters, allows the user to adjust the periodicity of the calculations it performs. This periodicity determines how the time dimension of the input metric (a measure) is segmented in the analysis.

At minimum, STL_Trend takes an input metric (Expression) and an integer value for its Period, returning a floating-point value. The input metric will be in the form of an aggregation that varies along the time dimension. Optionally, you can include values for the seasonal_smoother and trend_smoother to adjust the smoothing algorithm.


STL_Trend(Expression, period [,seasonal_smoother [,trend_smoother]])

Return data type: dual

Argument Description

The measure to decompose into Seasonal and Trend components. This should be a measure such as Sum(Sales) or Sum(Passengers) that varies along the time dimension.

This must not be a constant value.


The periodicity of the dataset. This parameter is an integer value representing the number of discrete steps that make up one period, or seasonal cycle, of the signal.

For instance, if the time series is segmented into one section for each quarter of the year, you must set the period to a value of 4 to define the periodicity as Year.


Length of the seasonal smoother. This must be an odd integer. The seasonal smoother uses data for a particular phase in the seasonal variation, over a number of periods. One discrete step of the time dimension is used from each period. The seasonal smoother indicates the number of periods used for smoothing.

For example, if the time dimension is segmented by month and the period is Year (12), the seasonal component will be computed so that each particular month of each year is calculated from data for the same month, both in that year and in adjacent years. The seasonal_smoother value is the number of years used for smoothing.


Length of the trend smoother. This must be an odd integer. The trend smoother uses the same time scale as the period parameter, and its value is the number of granules used for smoothing.

For example, if a time series is segmented by month, the trend smoother will be the number of months used for smoothing.

The STL_Trend chart function is often used in combination with the following functions:

Related functions
Function Interaction
STL_Seasonal - chart function This is the function used to compute the seasonal component of a time series.
STL_Residual - chart function When breaking down an input metric into seasonal and trend component, part of the measure's variation will not fit within either of the two main components. The STL_Residual function computes this portion of the decomposition.

For a tutorial with a full example showing how to use this function, see Tutorial - Time series decomposition in Qlik Sense.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!