RUNNING_AVG() Function in tableau

The RUNNING_AVG() function in Tableau is a table calculation function that calculates the running average of a given measure across a specified dimension. The running average in Tableau is the average of a measure calculated cumulatively as rows are added to the view, and it can be used to identify trends and patterns in the data.

The syntax for the RUNNING_AVG() function in Tableau is as follows:

RUNNING_AVG(expression,[start],[end])

where:

expression is the field or calculation to be aggregated.

start (optional) is the starting point for the running average. If not specified, the running average starts from the first row in the partition.

end (optional) is the ending point for the running average. If not specified, the running average continues to the last row in the partition.

Key features of the RUNNING_AVG() function in Tableau:

  • It is a table calculation function that calculates the running average of a given measure across a specified dimension.
  • It is useful for identifying trends and patterns in the data.
  • It can be used in combination with other table calculations, such as RANK() or INDEX(), to create complex calculations.
  • It can be customized by specifying a starting and ending point for the calculation.
  • It can be used to calculate a rolling average over a specified time period.

Note:

The RUNNING_AVG() function can only be used with continuous fields, and the aggregation must be set to SUM, AVG, MIN, or MAX.

Lets take 5 examples of the RUNNING_AVG() function in Tableau with their syntax

Example #1: Calculate running average in line chart

In below example we are calculating running average in Tableau of line for dual combined chart in tableau.

To calculate the running average of sales by Year in a line chart:

RUNNING_AVG(SUM([Sales]), FIRST(), 0)

Output will look like as shown below image

calculation of running average in tableau for combined dual chart

Example #2: Calculate running average in Tableau for stacked chart

To calculate the running average of profit by Region in a stacked bar chart, and running average in Tableau will show for two sales channels, online & offline channels.

RUNNING_AVG(SUM([Profit]))

Output shown in below imgae

output of running average in tableau for stacked chart

Example #3: Running average in Tableau of daily revenue

Calculate the running average of daily revenue in a area chart, which shows the daily revenue for 2010 year.

RUNNING_AVG(SUM([Revenue]), FIRST(), 0)

Output

output of running average in tableau for area chart

In each of these examples, the RUNNING_AVG() function is used to calculate the running average of a specific measure across a particular dimension. The optional start parameter is set to FIRST(), indicating that the calculation should start from the first row in the partition. The optional end parameter is set to 0, indicating that the calculation should continue to the last row in the partition. Finally, the SUM() function is used to aggregate the measure being analysed.

Scroll to Top