Video | Tableau | Analytics | AI & ML | Data visualisation

Predictive model improvements

Tableau 2020.4 lets you run regularised linear and gaussian predictive models in a calculation, and it's far simpler than wrangling R.

Watch on YouTube
  • MODEL_QUANTILE and MODEL_PERCENTILE let you run predictive analysis in a Tableau calculated field, with linear regression as the default model
  • Use a quantile of 0.5 to predict the median, so roughly half the values fall above and half below the line
  • Fix the 'cannot mix aggregate and non-aggregate arguments' error by wrapping the date predictor in ATTR() so everything is aggregated
  • Specify a model explicitly with the model = '...' syntax, using 'rl' for regularised linear regression and 'gp' for the gaussian process model
  • Tableau's documentation gives clear guidance on when to pick each model, and these calculations are far simpler to set up than the equivalent in R

Tableau 2020.4 adds predictive modelling functions you can write directly in a calculated field, letting you draw regression-based prediction lines without leaving Tableau or touching R.

Built on a simple Superstore line chart of sales over time. Assumes you know how to extend the date axis range, since that trick is reused here without explanation.

The Breakdown
  1. Build a basic line chart 0:35

    Put your measure on rows and a continuous date field on columns to get a simple timeline. This is just the base chart the prediction line will sit on top of.

  2. Write a MODEL_QUANTILE calculation 1:11

    Type MODEL_QUANTILE (or MODEL_PERCENTILE) in a calculated field and Tableau shows you the expected syntax: a quantile, a target expression and a predictor expression. Set the quantile to 0.5 to predict the median, so roughly half the data falls above the line and half below.

  3. Fix the aggregation error with ATTR 3:10

    If your predictor is a truncated date used alongside an aggregated target like SUM(Sales), you'll hit a 'cannot mix aggregate and non-aggregate arguments' error. Wrapping the date in ATTR() forces it to aggregate too, which resolves the conflict — this is a required fix, not optional, whenever you mix a truncated date predictor with an aggregate target.

  4. Plot it as a dual axis 4:13

    Drag the new calculated field onto the view next to your original measure, then dual-axis and synchronise the axes so the prediction line overlays the actual trend cleanly.

  5. Know the default model 5:01

    MODEL_QUANTILE and MODEL_PERCENTILE use linear regression by default, so the simple syntax without a named model is really just linear regression under the hood — confirmed by Tableau's own documentation on choosing a predictive model.

  6. Switch to explicit model syntax 6:01

    To choose a different model, rewrite the calculation using the longer MODEL(...) form that lets you pass a model = '...' parameter. Getting the quote marks and spacing exactly right matters — the function is strict about syntax.

  7. Try regularised linear and gaussian models 8:46

    Set model = 'rl' for the regularised linear model, which fits the general trend more loosely than standard linear regression, or model = 'gp' for the gaussian process model, which can follow the trend much more closely. You can comment lines in and out with the new block-comment syntax to compare models quickly without rewriting the calculation each time.

  8. Choose a model deliberately 10:54

    Tableau's documentation gives guidance on when to use each: linear regression for a single predictor with a linear relationship, regularised linear regression when you have multiple predictors with related underlying trends. Pick based on your data's structure rather than defaulting to whichever model happens to be first.

Worth Knowing
  • The MODEL syntax is fussy about exact placement of quote marks, commas and spacing — small formatting mistakes will throw errors that look unrelated to the actual cause.
  • These models aren't exclusive to Tableau; they're standard statistical models available in any stats tool, but Tableau's calculation syntax is far simpler to set up than doing the equivalent data framing work in R.
  • Switching models can produce only a subtle shift in the line, so test on a dataset/time frame where the difference is visible before concluding a model isn't working.
Use It When

Reach for this when you want a quick predictive trend line inside a Tableau view without exporting data to R or another stats tool, and you want the flexibility to try different regression models directly in a calculation.

How this Rollup was made provenance & method

A Rollup is drafted by AI from the video's transcript, then reviewed and edited by Tim. Everything used to produce this one is listed below — the model, the exact prompt, and the source video — so the process is transparent and reproducible.

Transcription
On-device — NVIDIA Parakeet v3 for recent videos, OpenAI Whisper large-v3 for earlier ones. The transcript never leaves the machine or gets published.
Drafting
Claude Sonnet 5 in the cloud, from that transcript.
Prompt
The exact Rollup prompt (v2) — the full system prompt, unedited.
Source video
Watch on YouTube
Drafted
5 July 2026 at 09:38
Reviewed & edited
5 July 2026 at 09:41 · by Tim Ngwena

Model + prompt + video is everything you'd need to recreate a Rollup like this yourself. The one thing we don't share is the transcript.

Rights. The video and its transcript are the property of TN Media Ltd. Unauthorised use or download is prohibited. © TN Media Ltd.