KNOWLEDGE BASE

How To Create A Calculated Field For Power Trend Line Equation


Published: 15 Sep 2020
Last Modified Date: 16 Sep 2020

Question

How to create a calculated field for power trend line equation 

Environment

  • Tableau Desktop

Answer

1. Create calculated fields LN X and LN Y as LN(X) and LN(Y) respectively 

2. Calculate the slope:

WINDOW_COVAR(ATTR([LN X]), ATTR([LN Y])) / WINDOW_VAR(ATTR([LN X]))

where WINDOW_COVAR returns the sample covariance of two expressions within the window and WINDOW_VAR returns the biased variance of the expression within the window

3. Calculate the intercept:

WINDOW_AVG(ATTR([LN Y])) - WINDOW_COVAR(ATTR([LN X]), ATTR([LN Y])) / WINDOW_VAR(ATTR([LN X])) * WINDOW_AVG(ATTR([LN X]))

4. The power trend line equation formula (trend line) :

EXP([intercept])*POWER(ATTR([X]),[slope])

5. Convert X and Y to dimension and drag them to view on rows

6. Go to Analysis -> Deselect the Aggregate Measures 

7. Drag trend line to rows besides X and Y and select discrete
 

Additional Information

Slope:

α = n∑(xy)−∑x∑y / ( n∑x2−(∑x)2)

Intercept

β = (∑y−α∑x) / n

Equation: 
User-added image

 
Did this article resolve the issue?