OpenBI Docs Buy

DECOMPOSE OpenBI

A time series' trend, season and remainder (STL, as R's stl), or how strong each is.

Group: Statistics. OpenBI’s own: DAX has no function of this name.

Syntax

DECOMPOSE ( <table>, <date>, <value> [, <period>] [, <model>] [, <what>] [, <seasonalWindow>] )
ParameterTypeDescription
tableTableThe rows of the series: one row an observation.
dateExpression
evaluated for each row
The date of each row, or a period's number (1, 2, 3 …).
valueExpression
evaluated for each row
The number observed, for each row.
periodWhole number
optional
How many observations make one cycle: 12 for months in a year, 4 for quarters, 7 for days in a week. Left out or blank, the dates' spacing decides.
modelText
optional
"additive" or "multiplicative"; "auto", the default, picks multiplicative if all the values are positive.
whatText
optional
"components" (the default) for a row an observation, or "stats" for a single row of shares and strengths.
seasonalWindowWhole number
optional
An odd number of cycles over which the seasonal pattern may change. Left out or blank, it is the same in every cycle (periodic).

Returns

Table. With "components": Date, Data, Trend, Seasonal and Remainder, a row an observation in date order. With "stats": one row with the Model and Period used, a share of the variation for each component (Seasonal share, Trend share, Remainder share), the Seasonal strength and Trend strength, the Seasonal window and the number of Observations.

Remarks

  • The method is STL, seasonal-trend decomposition by Loess. With the periodic default the components are R's stl with s.window = "periodic". With a seasonal window the season is smoothed with local lines, as statsmodels' STL does (R's stl with s.degree = 1).
  • Without a period, the dates' usual spacing sets it: 12 for months, 4 for quarters, 52 for weeks, and for days 7, or 5 when no date falls on a weekend. With numbers instead of dates, give the period.
  • Additive: Data = Trend + Seasonal + Remainder. Multiplicative: the series is split on its logarithms, and Data = Trend × Seasonal × Remainder, the Trend in the data's units, Seasonal and Remainder as factors around 1.
  • The shares are each component's variance over the sum of the three. A strength is one minus the remainder's variance over the variance of that component and the remainder added together, never below 0 (Hyndman's measure): near 1, a strong season or trend.
  • At least two full cycles are needed. The multiplicative model takes values above 0 only. Rows with a blank date or value are left out, and the rest sorted by date.

Compared with DAX

An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.

Examples

How seasonal are the monthly sales?

EVALUATE
SELECTCOLUMNS (
    DECOMPOSE ( VALUES ( Sales[Month] ), Sales[Month], [Liters sold], BLANK (), BLANK (), "stats" ),
    "Model", [Model], "Period", [Period],
    "Seasonal strength", [Seasonal strength], "Trend strength", [Trend strength],
    "Seasonal share", [Seasonal share], "Trend share", [Trend share], "Remainder share", [Remainder share]
)
ModelPeriodSeasonal strengthTrend strengthSeasonal shareTrend shareRemainder share
multiplicative120.9853954843462680.7382082214207060.947720859586270.03842793388387010.0138512065298596

The components of 2026

Every month sells more than nothing, so the model is multiplicative: July's season is about 1.31, 31 % above the trend.

EVALUATE
FILTER (
    DECOMPOSE ( VALUES ( Sales[Month] ), Sales[Month], [Liters sold] ),
    YEAR ( [Date] ) = 2026
)
DateDataTrendSeasonalRemainder
2026-01-014554950919.0686662660.8943468443712191.00021281877895
2026-02-014598551013.38754712120.8924549550515181.01005662565473
2026-03-014510951107.88113759930.8904521313886490.991207879324482
2026-04-014841651217.68701140360.9093427857726191.0395402723476
2026-05-015232951327.72880439791.010880641125081.00853391721795
2026-06-015963851438.32651506541.16337990130070.996585773404576
2026-07-016642351549.16253461371.306335793467390.986374976094684
2026-08-016035151651.03270803531.17751938629790.992287214339843
2026-09-015054951753.10419476110.9860957079584690.990505965927782
2026-10-014895351848.36006456750.9368806687959581.00776671345617

Additive, with a season that may change

EVALUATE
SELECTCOLUMNS (
    DECOMPOSE ( VALUES ( Sales[Month] ), Sales[Month], [Liters sold], 12, "additive", "stats", 7 ),
    "Model", [Model], "Seasonal window", [Seasonal window],
    "Seasonal strength", [Seasonal strength], "Trend strength", [Trend strength]
)
ModelSeasonal windowSeasonal strengthTrend strength
additive70.9953415557497670.890953279230405

TRENDLINE, LINESTX, CORREL, AVERAGEX.

Last updated · OpenBI Studio 0.3.74