Predictive Modeling Functions in Tableau

Predictive Modeling Functions in Tableau

Our today’s skill pill video is about Predictive Modeling Functions in time series visualisations. They can help you quickly generate predictions that can be manipulated, visualised, and exported later using table calculations. 

The first time when predictive modeling functions were introduced, was with Tableau 2020.3 version when many customers were eager to make predictions that don’t necessarily rely on a time axis and wanted also to export them to data files. 

This is how this new function was created based on statistical tools, that enabled analysts to create prediction models. Also, they were meant to offer flexibility, to access analytics without coding or managing extensions. The modelling functions are table calculations; therefore, you have the possibility to share visualisations and export data. 

Starting with 2021.2 version, trend lines and forecasts are available, and the statistical tool can comprehend your data and visualize the result in Tableau without integrating Phyton. This means data predictions with the help of table calculations. 

In conclusion, filter, aggregate and transform your data in the smallest detail and the model will automatically calculate your data. To extend a time axis into the future, so you can make predictions using this predictive modeling function, please follow the next steps: 

Step 1: Connect to data

→ In Tableau Desktop, connect to Sample – Superstore sample data provided by Tableau.

Step 2: Create the visualization

→ From the Data pane, drag the Order Date dimension to the Columns shelf.

→ Open the measure’s context menu to change its list level to Month and Year

→ Drag Profit to the Rows shelf

Step 3: Create a prediction calculation

→ Click to open the Analysis menu at the top, and then select Create Calculated Field.

→In the Calculation Editor, do the following:

Name the calculation: Quantile Predict Median Profit.     

Enter the following formula:

MODEL_QUANTILE(0.5, SUM([Profit]),ATTR(DATETRUNC(‘month’, [Order Date])))

→When finished, click OK.

The prediction calculation is now added as a calculated field in the Data pane.

Step 4: Add the prediction calculation to the view

→ Drag the prediction calculation to the Rows shelf, to the right of SUM(Profit).

→ Right-click (Control-click on Mac) the measure and select Dual Axis.

→ To align the two axes in a dual axes chart to use the same scale, right-click (Control-click on Mac) the secondary axis, in this case Quantile Predict Median Profit, and select Synchronize Axis.

This aligns the scale of the two axes.

Step 5:  Extend the date range and densify the data

The final step is to extend the horizontal axis into the future so that you can add marks beyond the current date range.

→ To do this, open the context menu of the MONTH (Order Date) pill, and select Extend Date Range.

→  In the Extend Date Range dialog, let’s extend the axis by 16 months.

Tableau has automatically updated the view by extending the horizontal axis and includes predictions on these future dates.

If you need to visualy see how it’s done, here it is the video created by Andreea Chiriac, Data Analyst at btProvider.

DOWNLOAD TABLEAU SOFTWARE