# Introducing Automatic forecasting

The **Advanced Analytics **section of the property panel for **Vizlib Line Chart contains the time series forecasting settings to **support a wide range of use cases, with three variations of the ARIMA model for you to select from.

This feature allows you to use statistical modeling techniques as used in forecasts for financial planning, demand forecasting, supply chain management, and scenario analysis.

**Automatic forecasting** gives you complete control of the forecasting parameters for your chart without having to code extensively or make complicated changes that require advanced knowledge of data science.

## Predictive forecasting algorithms - (S)ARIMA

**Vizlib Line Chart** uses the Auto-Regressive Integrated Moving Average (ARIMA) model to support predictive forecasting scenarios.

The main benefit of using an ARIMA model is that you don't need to define variables to run the forecast. And with Vizlib Library's Automatic forecasting, select the forecasting type you need, and the data points are automatically mapped on your line chart. **Figure 1** shows a line chart with automatic forecasting applied using the SARIMA algorithm.

**Please note**: Unless you have advanced knowledge of forecasting in analytics, we don't recommend changing any of the parameters or variables used in the **Forecast Settings**.

Figure 1: Chart showing the reference line that marks the start of the SARIMA-based forecast.

**TABLE OF CONTENTS**

- Introducing Automatic forecasting
- Selecting predictive forecast type
- Using Linear Regression forecasting
- Using Scenario Analysis forecast
- Predictive Data - Export to XLSX

## Selecting a forecast type

**Vizlib Line Chart** has three **Forecast Types:** **Predictive**, **Linear Regression,** and **Scenario Analysis**.

- Slide the
**Calculate Forecast**(**Figure 2**) toggle to the right to enable forecasting settings. - Click the checkbox beside the
**Show reference line indicator**to highlight the start of the forecast in the chart, as seen in**Figure 1**.

Figure 2: Select forecast output type.

## Set the Timeaware Axis to Active

For the forecast to work, you must:

- Click
**Appearance** - Click
**X-axis** - Slide the toggle for
**Timeaware Axis**to**Active**. If you don't enable this function, the error message 'Cannot create forecast if first dimension is not a Date' displays.

# Selecting predictive forecast type

**Predictive **is the default forecast type; use the dropdown list to select ARIMA, Advanced ARIMA, or Seasonal ARIMA for your forecast (**Figure 3**). This article uses Seasonal ARIMA as an example, as it contains all the settings used in the other options.

Figure 3: ARIMA Types

## Applying predictive forecast settings

Use the options in **Forecast Settings** (**Figure 4**) to help you manage the parameters used in the forecast.

The first three settings are simple parameters to help you project forecasts and adjust your forecasting model to your data.

**Number of points to****forecast**defines the number of data points to forecast when you enter a number in the expression field. The constraint for the maximum value is**period length × number of training periods x 0.5**. The training period is the amount of source data used to calculate the forecast.**Period Definition**defines the number of data points that constitute a period. For example, if days act as data points, seven (7) would define a weekly period and 91 a quarterly period. If months act as data points, 12 would represent an annual period.**Number of training periods**defines the number of periods used when calculating the forecast.

Figure 4: Predictive Forecast Settings

You can also choose an **Arima method **and** Arima optimizer**, but we don't recommend changing the default values unless you have advanced knowledge of forecasting.

## Setting numeric parameters

There are also several numeric parameters with default values already in place (**Figure 5**) - the **p Parameter**, **d Parameter**, **q Parameter**, **P Parameter**, **D Parameter,** and **Q Parameter**. Again, we don't advise making any changes to these values unless you have advanced knowledge of forecasting.

Figure 5: Parameters

## Setting forecast area and line colors

The **Forecast Area** settings control the look and feel of the forecast in the line chart (**Figure 6**).

- Slide the toggle to the right to enable a
**% Confidence Area.** - Use the
**Background Color**settings to select**Inherit Line**or**Custom.** - Set
**Area Background Color**using the color picker, or enter the hex color code in the expression field. - Use the slider to adjust the
**Area Opacity**percentage.

**Forecast Lines **allows you to select

- Slide the toggle to the right to set custom
**Line Styling.** - Set the
**Line Color**using the color picker, or enter the hex color code in the expression field. - Select a
**Line Style**from the list in the dropdown box.

Figure 6: Forecast Area, Forecast Lines

# Using Linear Regression forecasting

A Linear Regression forecast looks at the relationship between two variables by plotting a line through the observed data and works best when there is a relationship between the two variables (e.g. age and height, sales and advertising).

For the forecast, the line is extended and continues adding points that follow the regression line. The example in **Figure 7** uses a trendline that matches the regression forecast line comparing Average sales per day and Expense amount.

Figure 7: An example of a chart showing Linear Regression.

## Selecting the number of points to forecast

Use the expression field or click on the plus/minus buttons below (**Figure 8**) to set the **Number of points to forecast**; this affects all linear regressions for the chart object. All forecast lines must show the same number of points.

Figure 8: Number of points to forecast in a Linear Regression.

## Defining the regression period

In this section of the property panel (**Figure 9**), you can:

- Enter a custom
**name**for the linear regression. - Select the data for the
**Regression period definition**using the expression field or clicking the plus/minus buttons. - Set the
**Line Color**to**Inherit Line**color or use a**custom**color. Use the color picker, or enter the hex color code in the expression field. You also have the option to**delete**the customization. - Click the button
**Add Linear Regression**to add different regression periods to the forecast. This is useful when benchmarking more recent performance versus a longer period of time, for example, the last three months, last 12 months, or last 24 months.

Figure 9: Setting up a Linear Regression forecast

**Tip**: To get the count of all dates (where your measure exists), you can use an expression in the **Regression Period Definition** field, and we've included an example here:

=count(distinct {<Sales={">0"}>} Date)-1

# Using Scenario Analysis forecast

**Scenario Analysis** forecast types allow you to set up different future scenarios and work your way back to what that would mean for the business today. There are two scenario types you can add to the forecast - **Linear **and **% Growth**.

As with Linear Regression, you can add multiple scenarios for comparison and use expressions to make the forecast more data-driven (for example, re-calculating when you make a selection).

Linear scenarios (**Figure 10**) can be used to show the growth of nominal values between the last actual data point and the data point at the end of the next defined period (that is, 12 points later for a year, when data points are months).

Figure 10: Linear type of Scenario Analysis forecast showing Monthly sales per day compared with Expense amount.

## Defining details for a Linear scenario

In this section of the property panel (**Figure 11**), you can:

- Enter a custom
**name**for the scenario. - Select the value to use as a
**Measure**. - >Select
**Linear**for the**Scenario type**. - Enter an
**Increase per period**- this is an absolute value, added incrementally for each forecasted period. - Set the
**Line Color**to**Inherit Line**color or use a**custom**color. Use the color picker, or enter the hex color code in the expression field. You also have the option to**delete**the customization. - Click the button
**Add Scenario**to add different scenarios to the forecast.

Figure 11: Scenario Analysis - Linear type

## Parameter settings for both Scenario Analysis types

Both scenario types have parameter settings to control the **Number of points to forecast** and the **Length of Period **(**Figure 12**).

- Use the expression field or click on the plus/minus buttons below to set the
**Number of points to forecast.** - Define the
**Length of period**using the expression field or clicking the plus/minus buttons.

Figure 12: Parameters settings for both Scenario Analysis forecast types.

## Defining Growth % (percentage) scenarios

With Growth % scenarios (**Figure 13**), you can display scenarios where growth is accumulated and/or compounded, allowing you to visualize month-on-month or year-on-year growth; commonly used for financial or medical forecasts.

Figure 13: Growth % example using weekly UK Covid-19 cases

In this section of the property panel (**Figure 14**), you can:

- Enter a custom
**name**for the scenario. - Select the value to use as a
**Measure**. - Select
**Growth %**for the**Scenario type**. - Enter a
**Growth per period (%)**- each period grows by the percentage defined here. Use the expression field or the slider to define the percentage. - Set the
**Line Color**to**Inherit Line**color or use a**custom**color. Use the color picker, or enter the hex color code in the expression field. You also have the option to**delete**the customization. - Click the button
**Add Scenario**to add different scenarios to the forecast.

Figure 14: Growth % Settings

# Predictive Data - Export to XLSX

To export data to Excel (XLSX) on Qlik Sense or Qlik Sense Cloud (SaaS) with the forecasted data (see **Figure 15)** :

- Complete your changes and stop editing the sheet.
- Mouse over the top right of your chart to view the two options display, click the arrows to view the chart fullscreen, or click the three dots to display the
**context menu.** - Select
**Download as...** - From the options that display (Image, PDF, Export data to XLSX), select the option to
**Export Data to XLSX with forecasting**. This downloads the .xlsx file to your computer. - Open the file named:
**Vizlib Line Chart - Forecasting.xlsx**.

The exported file has two sections of data, so if required, you can recreate your charts within Excel with the original unpredicted data and have a comparison chart with the predicted data.

**On the left,**the**original data**with the**Dimension names**displays.**On the right**(the highlighted area in the chart image) is the data that has your**Dimension name**and the**Predictive**(DimensionName: Predictive*N*°*).*

Figure 15: File output when you select Export data to XLSX with forecasting.