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:
Create a Line Chart, dragging Order Date, at Week level and Continuous to Columns and Sum(Profit) to Rows.
Modify the Mark from Line to Circle.
Step 2: Create a Parameter to control the number of standard deviations
Click on the arrow on the right side of the Dimensions title in the left part of the screen.
Select Create Parameter.
Name the Parameter as Standard Deviations.
Select Data type as Integer.
Select AllowedValues as List.
Populate the list with values from 1 to 3.
Step 3: Create a Parameter to control the number of lookback periods
Click on the arrow on the right side of the Dimensions title in the left part of the screen.
Select Create Parameter.
Name the Parameter as Lookback Period.
Select Data type as Integer.
Set the CurrentValue to 20.
Select AllowedValues as Range.
Set the Minimum to 1 and the Maximum to 50.
Step 4: Create the Moving Average, Standard Deviation, Lower Bound and Upper Bound
Under Analysis->Create Calculated Field.
Name the Calculated Field as Moving Average.
Write the formula: WINDOW_AVG(SUM([Profit]),-[Lookback Period],0).
Right click the Moving Average field and select Duplicate.
Edit the duplicated field and rename it to Standard Deviation and change WINDOW_AVG to WINDOW_STDEV.
Create a field named Lower Bound Bollinger and write the formula: [Moving Average]-[Standard Deviation]*[Standard Deviations].
Right click the Lower Bound Bollinger field and select Duplicate, from your Tableau Desktop interface.
Edit the duplicated field and rename it to Upper Bound Bollinger and change the sign from “-“ to “+”.
Step 5: Create the Bollinger Bands
Drag MeasureValues to Rows.
Remove all other Measures from the MeasuresShelf except for UpperBound Bollinger, LowerBound Bollinger, Moving Average and Sum(Profit).
Modify the Mark of MeasureValues to Line.
Modify the Size of MeasureValues to a minimum.
Enable a DualAxis.
SynchronizeAxis.
Move the Marks from Sum(Profit) to Front.
Drag Measure Names to Color for MeasureValues and color Upper Bound Bollinger and Lower Bound Bollinger with Dark Grey, Sum(Profit) with Light Grey and MovingAverage with Green.
Right click the ParameterStandard Deviations and select Show Parameter Control.
Right click the ParameterLookback Period and select Show Parameter Control.
Step 6: Highlight Outliers
Create a CalculatedField called Outliers? Bollinger.
Enter the formula: SUM([Profit])>[Upper Bound Bollinger] OR SUM([Profit])<[Lower Bound Bollinger].
Drag Outliers? Bollinger to Color for Sum(Profit).
Color False and Null with Light Grey and True with Red.