Create Lines with Different Shapes in Tableau (v 2023.1 and Earlier)

By: Eric Parker

Pro Headshot.jpg

Eric Parker lives in Seattle and has been teaching Tableau and Alteryx since 2014. He's helped thousands of students solve their most pressing problems. If you have a question, feel free to reach out to him directly via email.

*June, 2023 Update:

Please note that Tableau has a new feature to allow for multiple types of lines in a single worksheet. The below is relevant to Tableau 2023.1 and earlier.*

—-

Tools like Excel and Google sheets give you the ability to create line graphs which can distinguish lines not only with different colors, but with different shapes. You can see in the chart below there is a yellow solid-line, a red dashed-line and a blue dotted-line.

158-1.png

Unfortunately, Tableau doesn’t offer that same capability. Below is an image of how close I have been able to get to recreating something similar to the above image (within a single worksheet).

158-2.png

We have the solid line, square line and the dashes. I’ll walk through how I did this.

Using Superstore data, I started by putting Month or Order Date on the Columns Shelf and Sales on the Rows shelf.

158-3.png

Notice that I converted Date Value Month of Order Date to be a Discrete field. That is important and will come into play in a little bit.

Next, I dropped the Profit field onto the Sales axis to create a shared-axis line graph.

158-4.png

The result looks like this.

158-5.png

After that I dropped another copy of Profit to the right side of the visual to create a dual axis chart.

158-6.png

The result looks like this.

158-7.png

By changing the mark type of the Profit section of the Marks card to square and then synchronizing the Profit axis to the other axis, I get what appears to be a line graph with squares for the data points.

158-8.png

The third “line” I added (orange dashes) was done with reference lines. That’s why it is so important to have the Month value be discrete.

I added the field (Cost of Goods Sold) to the Marks card, right-clicked on the Value axis, and added the reference line with the following settings.

 
158-9.png
 

After some formatting steps (hiding right axis, removing title from left axis, changing number format for left axis, customizing date format, customizing title) I have my finished product!

158-10.png

I did also play with the idea of using the reference lines as “squares”, replacing the squares on the green line with circles, and adding a proper line for the Cost of Goods Sold measure but felt it was too busy for this example.

158-11.PNG

That is as close as I know how to replicate that capability from Sheets/Excel lines. Drop a comment below if you have a more elegant solution!

 

Need help working through your own Tableau questions? Feel free to fire me and email or sign up for an Office Hour to supercharge your project!

Month to Date vs. Last Year Month to Date in Tableau

Visualizing My Family Tree in Tableau

0