Published: 06 Dec 2018 Last Modified Date: 15 Sep 2023
Question
How to create a candlestick chart to track stock data.
Environment
Tableau Desktop
Answer
Use a vertical line graph with a reference band per cell. The following directions utilize a sample data set which already has separate measures for the value of the stock at opening and closing, as well as the highest and lowest values that day.
Right-click and drag Date to the Columns shelf
In the Drop Field dialog, select Date (Discrete) with the blue # icon and click OK
Optional: right-click the x-axis in the view and select Rotate Label
Drag High to Text on the Marks card
Double-click Low in the data pane, which will automatically add Measure Names and Measure Values to the view
Drag Measure Values from Text on the Marks card to the Rows shelf
Remove Measure Names from the Rows shelf
Right-click and drag Date to the Columns shelf
In the Drop Field dialog, select MDY(Date) with the blue # icon and click OK
Drag Open and Close to Detail on the Marks card
Right-click the Value y-axis in the view and select Add Reference Line
In the Add Reference Line, Band, or Box, do the following:
Select Band
For Scope, select Per Cell
For Band From Value:, select SUM(Open), Minimum
For Band From Label:, select None
For Band To Value:, select SUM(Close), Minimum
For Band To Label:, select None
Click OK
Navigate to Format > Format Borders
In the left-hand Format Border pane, do the following:
Under Column Divider, drag the Level slider all the way to the right
Under Column Divider, select a thick white line in the Pane dropdown menu
Select Analysis > Create Calculated Field
In the Calculated Field dialog box that opens, do the following:
Name the calculated field. In this example, the calculated field is named "Bullish/Bearish"
In the formula field, create a calculation similar to the following:
IF SUM([Open]) > SUM([Close])
THEN "Bearish"
ELSE "Bullish"
END
Click OK
Drag Bullish/Bearish to Color on the Marks card
Thank you for providing your feedback on the effectiveness of the article.