Toan Hoang

Creating Bar with Trend Chart in Tableau

Sometimes, I will get an idea stuck in my head, an image, a type of data visualisation, and I will obsess about it until I have figured out how to create this in Tableau. The following is an example of this and based on feedback, I have written a tutorial about how to Create Bar Charts combined with a Trend.

Note: This is an alternative type of data visualisation, and sometimes pushed for by clients. Please always look at best practices for data visualisations before deploying this into production.

WARNING: This is a purely experimental chart type, and this tutorial is for learning purposes only. I still do not know if I would be able to find a use-case for this.

Data

We will start by loading the Sample Superstore data into Tableau.

Note: If you have Tableau Desktop, you can use the Sample data source, but if you are using Tableau Public, download and load the following data source.

Calculated Fields

With our data set loaded into Tableau, we are going to create the following Calculated Fields:

Index

FLOAT(INDEX())

LOD_Sales by Year

{ FIXED YEAR([Order Date]),[Segment]: SUM([Sales]) } / { FIXED YEAR([Order Date]): SUM([Sales]) }

Columns

(MAX(DATEPART('week', [Order Date]))-1.0)*MAX([LOD_Sales by Year])

TC_Line Height

SUM([Sales])/WINDOW_MAX(SUM([Sales]))

TC_Segment Sales

WINDOW_SUM(SUM([Sales]))

With this done, let us start creating our data visualisation.

Worksheet

We will now build our first worksheet:

If all goes well, you should now see the following.

Yes, this is a lot of work to simulate a simple bar chart, but the real fun is about to begin.

We will now add the trend line to our worksheet:

If all goes well, we should now have the following:

Now we will adjust the cosmetics to have our desired result.

You want to end up with the following:

How about using a line chart instead?

Or how about using Bar Charts?

in any case, I have to stress that this is super experimental, so please take this as a learning exercise. and with that said, boom we are done, and you can find my data visualisation on Tableau Public at https://public.tableau.com/profile/toan.hoang#!/vizhome/BarTrendChart/BarTrendChart

Summary

I hope you all enjoyed this article as much as I enjoyed writing it and as always do share the love. Do let me know if you experienced any issues recreating this Visualisation, and as always, please leave a comment below or reach out to me on Twitter @Tableau_Magic. Do also remember to tag me in your work if you use this tutorial.

If you like our work, do consider supporting us on Patreon, and for supporting us, we will give you early access to tutorials, exclusive videos, as well as access to current and future courses on Udemy:

Also, do be sure to check out our various courses:

Exit mobile version