The world’s leading publication for data science, AI, and ML professionals.

How to make a Comet chart in Tableau

I love storytelling using data. So, I am always on the look out for creative ways to represent data.

Photo by Justin W on Unsplash
Photo by Justin W on Unsplash

Comet Charts, as name suggests, are basically similar to bar charts but with a direction. So, they work great when you want to show comparison. For instance, comet charts can be used to depict sales in 2019 vs 2020 beautifully.Even though the concept makes sense, it’s not that widely used may be due to the application aspect.

I recently decided to use it anyways and I liked what I saw. So, I am writing today to illustrate how to build one in as simple way as I can.

Let’s start.


1. Get Dataset

The Comet chart works best when you want to compare some metric between two dimensions. So, I decided to use the Covid-19 Vaccine Willingness data set. You can get it from here.

2. Connect to dataset

The dataset downloaded is an xls format file. It threw error for me when I tried to connect it as a data source. So, you might want to open in excel and save as .xlsx and then try reconnecting.

3. Data Manipulation

The dataset is in wide format as shown below. We need to convert it into long format.

So, once you connect the file as a data source, click on the top of all columns except DateTime, right click and select Pivot.

Image by Author
Image by Author

Your data should look like this now. Rename the Pivot Field Names as Country and Values as Willingness.

Image by Author
Image by Author

Next, we need to create few fields-

Willingness in 2020

Image by Author
Image by Author

Willingness in 2021

Image by Author
Image by Author

Difference between the two

Image by Author
Image by Author

Sign function gives the sign of the calculation. Positive is represented by 1, negative by -1 and zero is represent by 0. This will be used to highlight the positive and negative change in the metric.

4. Drag and drop!

Now, just drag Country to Rows shelf and measure values to column shelf like you would do for a horizontal bar chart.

  • Add Avg Willingness 2021 and Avg Willingness 2020 to Measure Values card.
  • Drag Measure Names to Path and Size.
  • Drag the Sign field(diff in my case) to colour.

Voila! The comet chart is ready. Your output would look something like this.

Image by Author
Image by Author

You can customise it further like add labels, change sheet formatting add more information in tooltips etc.

Here’s my final version. I have added detailed trends for each country in the tooltip along with the %change.

Image by Author
Image by Author

You can find the complete viz here.

I hope you find this information useful! Please feel free to leave any questions in the comments.

Happy Learning!


Related Articles