This is the third and final part in the Tableau parameters series.

While Tableau has a built in Moving Averages calculation, it is preset to only the previous 2 periods. But what if the user wants to look at the moving averages over a longer period of time? Dynamic Moving Averages are a great way to give the end user control over how many previous periods they wish to use for the moving average calculation.

Let’s get started.

Firstly, we will building a standard moving averages chart on a dual axis with a standard sales over time chart using sample superstore data.

Creating the Dual Axis Chart

  1. Drag sales on to the rows shelf, and order date on to the columns shelf. Change Order date to a continuous month.
  2. Hold control and click and drag your sales pill currently on rows to rows again.
  3. Right click on the sales pill on the rows shelf and change it to moving average.
  4. Right click on the same sales pill on the rows shelf select Dual Axis.

Creating and using a Parameter

Next, create a Parameter to select the number of months to use for the moving average calculations.
Give it a meaningful name (Number of Months for Moving Average).
Change the range to your minimum and maximum month range (the example below uses 2 months as a minimum and 30 months as a maximum range).

Thirdly, double click on the moving average sales pill.
Where it shows -2, replace the 2 (keep the negative) with the new parameter.

Synchronize the Axis

Finally, synchronize the sales axis by right clicking and selecting ‘Synchronize Axis’.

Your dynamic moving average chart dual axis with a sales over time chart is now complete.

If you are ready, give this challenge a go:
2021 Week 33 | Tableau: Can you create a moving average chart with a focus on selected subcategories? – Workout Wednesday (

The Data School
Author: The Data School