 # Tableau Software – Skill Pill – Bollinger Bands (EN) Bollinger Bands are a type of statistical chart used to characterize prices and volatility over time. The visualization can be applied to areas that are outside of finance and trading, using the principle behind it we can view for instance sales or profit using a moving average rather than a global average, as in control charts, thus we can detect anomalies in a much smaller frame with a smaller seasonality than our view.

In order to create a Bollinger Band in Tableau, please follow these steps:

Step 1: Create a Line Chart

1. In Tableau Desktop, connect to Superstore sample data provided by Tableau.
2. Create a Line Chart, dragging Order Date, at Week level and Continuous to Columns and Sum(Profit) to Rows.
3. Modify the Mark from Line to Circle.

Step 2: Create a Parameter to control the number of standard deviations

1. Click on the arrow on the right side of the Dimensions title in the left part of the screen.
2. Select Create Parameter.
3. Name the Parameter as Standard Deviations.
4. Select Data type as Integer.
5. Select Allowed Values as List.
6. Populate the list with values from 1 to 3.

Step 3: Create a Parameter to control the number of lookback periods

1. Click on the arrow on the right side of the Dimensions title in the left part of the screen.
2. Select Create Parameter.
3. Name the Parameter as Lookback Period.
4. Select Data type as Integer.
5. Set the Current Value to 20.
6. Select Allowed Values as Range.
7. Set the Minimum to 1 and the Maximum to 50.

Step 4: Create the Moving Average, Standard Deviation, Lower Bound and Upper Bound

1. Under Analysis->Create Calculated Field.
2. Name the Calculated Field as Moving Average.
3. Write the formula: WINDOW_AVG(SUM([Profit]),-[Lookback Period],0).
4. Right click the Moving Average field and select Duplicate.
5. Edit the duplicated field and rename it to Standard Deviation and change WINDOW_AVG  to WINDOW_STDEV.
6. Create a field named Lower Bound Bollinger and write the formula: [Moving Average]-[Standard Deviation]*[Standard Deviations].
7. Right click the Lower Bound Bollinger field and select Duplicate, from your Tableau Desktop interface.
8. Edit the duplicated field and rename it to Upper Bound Bollinger and change the sign from “-“ to “+”.

Step 5: Create the Bollinger Bands

1. Drag Measure Values to Rows.
2. Remove all other Measures from the Measures Shelf except for Upper Bound Bollinger, Lower Bound Bollinger, Moving Average and Sum(Profit).
3. Modify the Mark of Measure Values to Line.
4. Modify the Size of Measure Values to a minimum.
5. Enable a Dual Axis.
6. Synchronize Axis.
7. Move the Marks from Sum(Profit) to Front.
8. Drag Measure Names to Color for Measure Values and color Upper Bound Bollinger and Lower Bound Bollinger with Dark Grey, Sum(Profit) with Light Grey and Moving Average with Green.
9. Right click the Parameter Standard Deviations and select Show Parameter Control.
10. Right click the Parameter Lookback Period and select Show Parameter Control.

Step 6: Highlight Outliers

1. Create a Calculated Field called Outliers? Bollinger.
2. Enter the formula: SUM([Profit])>[Upper Bound Bollinger] OR SUM([Profit])<[Lower Bound Bollinger].
3. Drag Outliers? Bollinger to Color for Sum(Profit).
4. Color False and Null with Light Grey and True with Red.

By Alexandru Stancescu