top of page
Writer's pictureBernard Kilonzo

Proper way to sort sunburst chart in Tableau


sorting sunburst chart in tableau

Introduction

Sunburst chart is used to visualize hierarchical data through a series of rings that are partitioned into different categories. Each level of the hierarchy is represented by one ring – with the inner most ring being the top of the hierarchy.

Example of sunburst chart

example of a sunburst chart

This article is not about how to create a sunburst chart in Tableau. I have created an extensive article that covers that. You can read more about the article here.

This article specifically focuses on how to properly sort your sunburst chart in Tableau. But before that, let’s look at the problem first.

The Problem

When you sort fields in the sunburst chart, normally Tableau preserves the sorting order from one category to another. See in the attached view.

problem when sorting sunburst chart

(From the above view – and looking at the starred categories, you can see that Technology category is ranked 1st across the different product Segments when indeed it’s not the top performing category for the Consumer segment. The same applies to the product Sub-Category, where the Art Sub-Category is ranked 1st for the Office Supplies Category a scenario that does not hold true for Consumer and Home Office segments).

The Solution

The proper way to sort fields in the sunburst chart is by first making the categories unique for the levels that have distorted sorting (where sorting order is preserved).

You can make the categories unique by creating combined fields. For this case, I am experiencing the sorting problem at Category and Sub-Category levels (2nd and 3rd ring). To rectify this, I will create two combined fields.

  • Category & Segment – (which combines the dimension Category and Segment)

  • Category, Segment, Sub-Category – (which combines the three dimensions)

Next, I’ll add these combined fields in the hierarchy field – just before the dimension Category and Sub-Category.

See below.

Tableau hierarchy fields

To correct the sorting problem at level 2 (2nd ring)

  • Drag the hierarchy field to the Detail shelf.

  • Drag the measure field (Sales in this case) to the Angle shelf.

  • Expand the hierarchy up to Category level.

  • Sort the dimensions ‘Segment’ and ‘Category & Segment’ in descending order by a field – (in this case by Sales).

  • Change the dimension Category from Detail to Color.

See below.

sorting level two of sunburst chart in tableau

To correct the sorting problem at level 3 (3rd ring)

  • Drag the hierarchy field to the Detail shelf.

  • Drag the measure field (Sales in this case) to the Angle shelf.

  • Expand the hierarchy up to Sub-Category level.

  • Sort all the dimensions before Sub-Category in descending order by a field – (in this case by Sales).

  • Change the dimension Sub-Category from Detail to Color.

See below.

sorting level three of sunburst chart in tableau

Notice that, by making these few adjustments to the viz – all the dimension members are properly sorted in descending order by Sales at every level.

See below.

properly sorted sunburst chart in tableau

Conclusion

I hope this article was helpful to you. If you wish to receive more Tableau tips and tricks, kindly join our mailing list by subscribing below.

If you like the work we do and would like to work with us, drop us an email on our contacts page and we’ll reach out!

Thank you for reading!

Blog.png
bottom of page