# Introduction

Full viz here.

There are some great examples showing off ways to build a sunburst chart in Tableau. Bora Beran wrote an excellent tutorial here. More recently Toan Hoang wrote a similar approach here.

Both approaches rely on three elements that make the viz a bit difficult to build:

• Data reshaping
• Densification
• Table Calculations

I wondered if there was a way to reduce the number of steps to make a sunburst. After all, the power of Tableau is that you spend more time exploring your data than building the viz or coding.

I wasn’t able to completely remove the complexity, but this approach is somewhat faster than previous ones.

# What is a sunburst chart?

A sunburst chart is used to show hierarchical data. Each slice can be quantified, or it can simply represent higher levels in a chain (chain of command). For quantified slices, a great example is the product hierarchy in the default Sample – Superstore data. Properly built, a Sunburst can provide quick insights into problem areas within a quantified whole.

The view below shows sales for each item, colored by overall profitability.

I can quickly see several orange slices in the hierarchy that would have otherwise been concealed by looking at each level individually. Bookcases, Furniture, and Supplies are highly unprofitable. However, one step down, there are several items in the Machines sub-category that are causing significant profit losses.

All of this at a glance.

# How To

Time to complete: 7 minutes

The method that I employed takes four basic steps.

• Pivot the fields that will be in the sunburst, putting all members into a single dimension.
• Join the original table back into the data, hiding all fields except for the fields that have been pivoted.
• Create 3 calculations:
• One to appropriately position (and separate) the hierarchy into concentric circles
• One to sort the slices (and indicate the correct hierarchy)
• One to display the correct total sales at the top level.

## One Pivot

1. Connect to the data source.
2. Select the fields that will be in the sunburst
3. Right-click and select pivot
4. Name the fields something easy to remember.
1. Pivot Field Name = SB – Level
2. Pivot Field Values = SB – Member

## One Join

1. Join Orders to Orders (renamed Categorical)
2. Hide all fields other than the original Hierarchy fields

## Three Simple Calculations

1. Build the position calculation (X)
1. (IF [SB – Level]=’Category’ THEN 1
ELSEIF [SB – Level]=’Sub-Category’ THEN 3
ELSE 5 END)/10000
2. This calculation cheats Tableau into positioning each level imperceptibly separate from the others. I took this idea from Adam E McCann and his awesome Star Wars viz.
2. Build the sort calculation (Sort)
1. IF [SB – Level]=’Category’ THEN ‘All’
ELSEIF [SB – Level]=’Sub-Category’ THEN [Category]
ELSE [Sub-Category] END
2. This calculation defines the level above the current one, allowing us to perform a nested sort. I honestly suspect there’s another way to do this, if you find it let me know!
3. Build a calculation to compute Total Sales
1. {INCLUDE [SB – Level]: SUM(Sales)}
4. Add MAX(Total Sales) to the inner circle to display the correct Total Sales.

## Build the View

Essentially it’s a multi-layered donut chart.

1. Add the MAX(X) and make the mark type a Pie chart. (The screenshot shows AVG, but the view broke when I took an extract. Not quite sure why, but be forewarned about that).
2. Add MIN(X) to the view and make the mark type a circle
3. Synchronize the Axes and pin to -1 and 1
4. Add the fields above to the view.
1. SUM(X) on Size
2. SUM(Sales) on Angle
3. Category, Sort, SB – Member, and SB – Level on the details shelf in that order (color as desired).
5. Sort the field Sort and SB – Member descending by the sum of Sales

# Caveats

• Adjusting the sizing can be a bit tricky. I’d say that getting the sizing right was the most difficult portion. Use the Edit Sizes option in the Size legend drop-down to fine tune the slice sizes.
• Data reshaping is not always available as an option. Another tool such as Alteryx may be needed to properly prep the data.
• Sorting requires a unique hierarchy. I have not attempted to do this with dimensions that are not a hierarchy such as Segment or Region. It should work quite similarly, but the sorting will require a different approach.
• There have to be members at every level of the hierarchy and all levels have to add up to 100%. Some sunburst charts do not need the chart to go all the way around the circle. This method requires it.
• Size explosion. For every level in the Hierarchy, the data will multiply by that number. Superstore is about 10,000 records. The final product was about 30,000 because there were 4 levels.

# Extending the concept

The method for shaping the data in a sunburst can be broadly applied to other types of networked data. While I haven’t attempted to yet, I am fairly certain that I could use some of the steps above to build a network diagram or a market basket analysis. There may also be a way to use this for a Sankey diagram as well.

## 6 thoughts on “Sunbursts in Tableau: One Pivot, One Join, & Three Simple Calculations”

1. thoang1000 says:

Very interesting approach. Thanks for the mention

Like

2. Shama Shrivastav says:

Interesting but not able to get it right. Despite following the steps correctly.

Like

1. Hey Shama, I’d love to help out. Can you tell me a bit about what is or is not working?

Like

3. You saved my day! Thank you for your brilliant approach!

Like

4. Hi, As followed your steps as it is, but the actual output is not getting, not sure where would I messed up the steps. If you’ve video tutorial on this, could help us a lot.Thanks.!

Like

1. Hi Narasimha, I do not have a video made on this unfortunately. I’m pretty busy these days and don’t think I’ll have time to build a video anytime soon. I suggest trying the steps with Superstore first. Then, I suggest ensuring that there are no NULLs in any of your dimensions.

Those are the two most common ways to troubleshoot the steps. Hopefully this helps!

Like