---
title: "Use the SEASONALLINEARREGRESSION Function to Analyze Seasonal Trends"
slug: "seasonal-linear-regression-function"
description: "Learn to use SEASONAL.LINEAR.REGRESSION to compute a linear trend with seasonality adjustments in Pigment for time-based data analysis."
updated: 2025-05-28T10:26:33Z
published: 2025-08-22T12:00:18Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://kb.pigment.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SEASONAL_LINEAR_REGRESSION function

## Description

Computes a linear regression by fitting a straight line to the data and taking seasonality into account.

## Syntax

`SEASONAL_LINEAR_REGRESSION(Input Block, Seasonality [, Ranking Dimension])`

## Arguments

| Argument | Type | Dimensions | Description |
| --- | --- | --- | --- |
| *Input Block* (required) | Number | Any Dimensions | This is the data source on which the seasonal linear regression is computed, and must be a Metric with data points as an expression of Integer or Number type. This Metric must include the same Dimension that is used in the `Ranking Dimension` argument. |
| *Seasonality* (required) | Integer | No Dimension | Length of the seasonality. It must be greater than 1, for example, if you observe a quarterly on a Metric defined by month, the Seasonality length is 3. If you observe a yearly seasonality on a Metric defined by month, the Seasonality length is 12. |
| *Ranking Dimension* (optional) | Dimension | Not applicable | This is a Dimension applied to the time series taken in the `Input Block`. This is optional if it’s a datetime Dimension from the calendar. If this is not the case, then this is mandatory. It’s also mandatory if the Metric is defined on several time Dimensions. |

## Returns

| Type | Dimensions |
| --- | --- |
| Number | Dimensions of *Input Block* |

With N being the Seasonality length of the serie, the function returns:

- Blank for value before the first non blank value.
- (*A* * x +*B*) * *SeasonalityFactor*(x) after the first non blank value

To compute *SeasonalityFactor*, *A*and *B*, we use the classical decomposition method, called multiplicative decomposition, over historical data.

> Notes:
> 
> - Blank observations (in the input Block) between the first non-blank value and the last non-blank values are considered as 0.
> - The function requires 2 times the seasonality in terms of datapoint between the first non-blank value and the last non-blank values.

## Examples

| Formula | Description |
| --- | --- |
| `SEASONAL_LINEAR_REGRESSION(Actuals, 4, Quarter)` | Computes a yearly seasonality over a metric defined by quarter. |
| `SEASONAL_LINEAR_REGRESSION( Actuals, 12, Month)` | Computes a yearly seasonality over a metric defined by month. |
| `SEASONAL_LINEAR_REGRESSION( Actuals, 3, Month)` | Computes a quarterly seasonality over a metric defined by month. |

Example using `SEASONAL_LINEAR_REGRESSION(Actuals, 4)`:

![](https://cdn.document360.io/e47cfe35-dc28-40c7-a083-6cf003073d8e/Images/Documentation/86c33967-3e00-4749-bf55-a908058e8482.png)

## Using SEASONAL_LINEAR_REGRESSION as Forecasting Function

A common use case for using the SEASONAL_LINEAR_REGRESSION function is to prepare a forecast. It’s a good method when your observation series shows a linear trend****and a seasonality.

## See also

Related articles: [FORECAST ETS](/v1/docs/forecast-ets-function) , [FORECAST_LINEAR](/v1/docs/forecast-linear-function)

[References: [Multiplicative decomposition](https://otexts.com/fpp3/classical-decomposition.html#multiplicative-decomposition) , [wikipedia](https://en.wikipedia.org/wiki/Decomposition_of_time_series)]

<style> p[data-block-id] {font-size:1rem;} ul li p[data-block-id] {margin-bottom: 0;} ul[data-type="taskList"] li div p[data-block-id] {margin-bottom: 0;} ol li p[data-block-id] {margin-bottom: 0;} table tbody th p[data-block-id] { margin-bottom: 0;} blockquote p[data-block-id] {margin-bottom: 0 !important;} &nbsp;p[data-block-id]:empty::after {content: "\00A0";} </style>
