# Trend and Forecasting

Contents[Hide]

The Trend and Forecasting function applies a regression function to historical data in order to forecast future values based on the best fit.

This function is typically used with a datetime axis but it will also work with a numeric hierarchy or measure for alignment.

## 1. Syntax

Trend and Forecasting:

```TRENDFORE(d0,d1,s0,s1,s2)
```

Upper Band Error:

```TRENDFOREUPPER(d0,d1,s0,s1,s2)
```

Lower Band Error:

```TRENDFORELOWER(d0,d1,s0,s1,s2)
```

## 2. Input

The Trend and Forecasting functions require the following input series:

• d0 - Trend Axis values - The set of values on the trending axis (e.g. datetime axis).
• d1 - Input data values - The set of historical data values to be used in the Trend and Forecasting formula.

## 3. Parameters

• s0 - Regression Type - The type of regression function used by the Trend and Forecasting formula. Available choices include:
• 0 - Linear (default)
• 1 - Exponential
• 2 - Logarithmic
• 3 - Power
• s1 - Regression Degree - The degree used by the regression function in calculating the Trend and Forecasting formula. Default value is 2.
• s2 - Forecasting Period - The length of the forecasted data series as returned by the Trend and Forecasting formula. Available choices include:
• 0 - No Forecast
• 1 - Tenth Input
• 2 - Quarter Input
• 3 - Half Input (default)
• 4 - Full Input

## 4. Output

The Trend and Forecasting functions generate the following outputs:

• Trend and Forecasting - The Trend and Forecasting result set.
• Upper Band Error - The upper error boundary based on standard deviation and the forecasting error.
• Lower Band Error - The lower error boundary based on standard deviation and the forecasting error.

## 5. Examples

### 5.1. Linear regression on scatter plot

This example shows how to use the TRENDFORE function on a scatter plot chart. You can also do these steps in the Metric Set Designer.

First, create a new dashboard and add a Scatter Plot data visualization from the toolbar.

Add two measures (LineTotal, OrderQty) and one row hierarchy (OrderDate). Edit the OrderDate hierarchy and change its Level to Month.

With the chart selected on the canvas, go to the toolbar, click Data Tools, and then select Add Formula.

In the formula bar, type the following and click apply:

`TRENDFORE(\$OrderQty\$,\$LineTotal\$)`

Right-click on the generated regression series and re-visualize it as a Line series.

## 6. Notes

• The forecast will only go until the end of the time dimension or until the end of the OLAP time hierarchy.