Manually Calculating Trend Lines

Published: 28 Apr 2015
Last Modified Date: 29 Jul 2020


How to calculate trend lines manually so values such as slope can be accessed as a field.


Tableau Desktop


Tableau returns values like slope of trend line, covariance, R-squared and Pearson correlation coefficient when you add a trend line and then select "Describe Trend Model". For more information about trend lines please see Add Trend Lines to a Visualization.

Option 1

  1. Right-click the trend line and select "Describe Trend Models"
  2. Copy the trend line model equation in a calculated field.
However, please note that as data changes (i.e. data is filtered or excluded), the calculated fields would need to be updated. For more information regarding this method, please refer to the reply in this Community post.

Option 2

Use table calculations to calculate the trend line and slope. To view an example, see the attached workbook called trend line generic.twbx.

Option 3

In Tableau 10.2 it is also possible to use the COVAR() function to create a calculated field which returns the slope of a trend line. For more information about how this can be done please see Covariance, Trend Lines, Correlation Coefficient R and R-Squared in the Community.
Did this article resolve the issue?