KNOWLEDGE BASE

How to display trend lines with standard deviation added


Pubblicato: 25 Aug 2022
Data dell'ultima modifica: 26 Aug 2022

Domanda

How to add standard deviation to the trend line.

User-added image

Ambiente

  • Tableau Desktop

Risposta

The following is an example of setting a trend line and a trend line + standard deviation (σ) for Sales and Profit scatter plots.

1. Set Profit to Columns.
2. Set Sales to Rows.
3. Select Menu > Analysis > Aggregate Measures.
4.Create a calculated field and name it Slope.
WINDOW_COVAR(SUM([Profit]), SUM([Sales])) / WINDOW_VAR(SUM([Profit]))

5. Create a calculated field and name it Intercept.

WINDOW_AVG(SUM([Sales])) - WINDOW_COVAR(SUM([Profit]), SUM([Sales])) / WINDOW_VAR(SUM([Profit])) * WINDOW_AVG(SUM([Profit]))

6. Create a calculated field and name it Standard Deviation (σ).

WINDOW_STDEV(ATTR([Sales]))

7. Create a calculated field and name it Trend Line +σ.

[Slope] * ATTR([Profit]) + [Intercept] + [Standard Deviation (σ)]

9. Set Trend Line +σ to Rows.
10. On the Marks card, open Trend Line + σ and the mark type to Line.
11. Right-click Trend Line +σ on Rows and select Dual Axis.
12. Right-click on the right axis and select Synchronize Axis.
13. Right-click on the right axis and uncheck Show Header.
14. (If needed) Open Analytics pane and drag Trend Line to Sales of Linear.

Con questo articolo hai risolto il problema?