Hello and welcome to Part 2 SuperDataScience
 Sunburst Chart tutorial. If you
haven't been through part 1 I'd highly
recommend going back and walking through
that. As we walk through data preparation
both inside of Excel to transform the
data so it's properly formatted for the
Sunburst chart. We also work with data
preparation inside of Excel so you can
duplicate it properly and get things set
up for our data densification that
we're going to need to do. But building
off of those assume you've already done
those well let's dive in to building out
our Sunburst Chart. Coming back to our
data the first step that we're going to
need to do is our data densification.
Data densification uses this column ToPad
and you start out by creating bins.
Will call it Padded. Again, data
densification is often called padding
your data. Then we have to look at what this
is doing in order to properly understand
it. If you look at ToPad we have two
values for our data set. We have 1 and
we have 203. So we have
the 50 rows for 1 and 50 rows for 203.
But if we try Pad it out, we actually
have the values 1 2 3 4 etc all the way
through 203. This happens because the bin
function is what's called range aware.
When you create bins it finds the
minimum value of 1 by the maximum values
203 but then when you tell it to create
a bin of size one Tableau's engine
goes in and effectively creates a blank
bin for every single value in between
your max and your min. So what we've done
is inside of Tableau's engine said - "Hey
we want all of these values in there
even though they don't exist in our data
set". The cool thing about this is then
you can use table calculations let's use
index then one of the most basic and
common table calculations just returns
the current row of the partition. You
bring index up your column you notice we
have two values 203 and 1. But then if
you compute using Padded the table
calculation will actually comprehend
what's going on inside of that
densification and return a value for
each of those bins. What you can then do
is combine this with other more advanced
calculations especially table
calculations to draw marks on those
values even though they didn't exist in
your data set. This is the essence of
data densification and data padding and
now that you've done that you're ready
to go. Okay now that we check that a data
densification is working we've cleared
our view we're ready to build out the
calculations
required to build our Sunburst Chart.
At this point again give credit where
credit's do Bora Beran is the man who came
up with these calculations. He's the one
who built out the advance table
calculations used the data
densification and use the advanced
trigonometry that frankly is way beyond
me in order to create this and so we owe
him a lot of credit. To that point we're
actually going to come in and just use
the calculations that exist in our
practice workbook. And we'll copy those
right there and we'll come in and we'll
paste them. This will save me a lot of
typing save you guys a lot of boring
watching me type and I'll actually go
through and describe these and then
we'll show you how to build it and
especially build out the nested table
calculations. First off we already have
our index calculation that we did before
Just shows the current row of the
partition allows us to comprehend the
data densification that's happening. Max
level is a window calculation that
returns what level you're on. So if you
look at our chart with us as level 1
level 2 level 3 level 4 and by wrapping
it inside of a table calculation it will
comprehend the data densification that's
going on and be able to calculate it
correctly for every view. Max sales is
the exact same thing as max level except
it returns your sales value. So you'll be
able to get a proper sales value for
every one of the marks that you're
drawing. Slice level, right here, again
returns the max level but we keep it
separate just in terms of readability in
terms of our calculations. Slice size
looks and creates a percent of total
calculation across this view. So you have
your four Regions for your level. In this
first level and it creates a percent of
total based off of sales so if you
figure out how to exactly divide this
view. Then looking at your edges right
here, I skipped this intentionally, it
uses some lookup functions to look at
the previous max levels that you were on
and the slice sizes you're on to figure
out where to draw these edges in between
your views. So you have your sizes but
you also need to be able to comprehend
where those edges are to where you can
start splitting up to different
dimensions. And then here's the kicker
when you're drawing points in Tableau
you can think of it as drawing it on a
Cartesian coordinate so you have your x
axis horizontally you have your y axis
vertically these two calculations x and
y together will create a point or an
address where Tableau will then come in
and draw the marks. So I'm going to just
open this and let you look at that for a
little bit and we can all sit back and
thank Bora Berans amazing work that
he's done. This is a parametric equation
you can tell that it is because it's
using cosine it's using PI and it's
using the table calculations that we had
in order to comprehend things. Basically
I'm not going to try and explain all of
this because it's honestly beyond me and
we owe him a big thanks, but what it does
in effect, is it draws this circle that
we want along the different edges. So
this creates the x coordinate that we
need and then this calculation creates
the y coordinate that we need. So again y
if you're familiar parametric equations
use a sine and PI x uses cosine in PI.
But that's about the extent of my
knowledge on those parametric equations.
At this point I click through all of our
calculations that we're going to use.
I would recommend as you're building this
chart out yourself either going to Bora Berans
 blog. You can just boraberan.wordpress.com and looking at radial
tree maps or you can pause the video as
I was going through and then write out
the calculation based off of that.
Whatever works best for you.
Now that we have our calculations set
we're going to come in and we're going
to actually build our view. It's very
exciting. First we're going to add in the
dimensions that we care about. We want
our Region our Segment our Product
Category and then our Brand. Remember
this order, because it's going to be the
order from the inside to the outside
it's going to be very important for our
table calculations. So Region Segment
Product Category and Brand. Then we're
going to take our x value drag it up
we're going to take our y value drag it
up. And you're going to see we have a lot
of nulls and something starting to show
up. We're also going to need to bring in
our Padded. And we're going to need to
bring in what level we're on. And then
most importantly we're going to need to
bring in the Polygon Chart. And I'll drag
Padded up to our path. So the Polygon
Chart does is it's going to take this X
and this Y and then draw a mark on the
coordinates for where X and Y are. Very
important to use that and it's really
the crux of this technique. So now that
we have our view set up we actually come
here
and edit our table calculation. And now
we're going to use nested table
calculations. Nested table
calculations are an advanced technique
where you recalculate the table
calculation at different levels based
off of the other calculations that make
up your table calculation. So we have X
index, SliceLevel, Edges, MaxLevel, SliceSize
 and MaxSales. We're going to go
through and tell it exactly where it
calculate. So remember I said that order
was important. We want Region, Segment
Product Category, Brand and then we have
Level and Padded. For X we needed to
comprehend everything that's going on.
For index just like in our example we
only needed to comprehend Padded. So we
can find all the values on our view. For
SliceLevel we're going to need to do
Region, Segment, Product Category, Brand.
And then because it's trying to figure
out level we don't want it to include
level or else it'll be a bit of a
circular calculation. For Edges we are say
Region, Segment, Product Category and
Brand. And we also wanted to calculate
what level it's on. So I can know
probably when to end level here or here
depending on which one you're using.
For MaxLevel that one we just wanted to
comprehend the Padding so it'll give us
the proper level for each of our marks.
SliceSize we want it to calculate and
according to everything that we have. So
Region, Segment, Product, Brand, Level and
Padded. And then for MaxSales again we
just want it to be available based on
wall or a padded values. Now that X is
taken care we're going to go in and do
the exact same thing for Y. So for a
Y-value we want it to have everything
that's in the view. So we have Region, Segment, Product Category, Brand Level and
Padded. Index we want it show Padded. SliceLevel again I told you to remember this
and you're probably getting tired of
seeing it that we have Region, Segment
Product Category, Brand and then we're
going to skip the Level and do Padded.
For edges,
were go in Region, Segment, Product Category
Brand and Level. MaxLevel we just need
Padded. SliceSize we need everything.
And then for MaxSales we're going to
need it across Padded. And there you go!
This incredibly exciting, now we have our
chart showing up. So we're going to
format this really quick we're just
going to go this a nice white blank
canvas to work on. A modern look in terms
of design. Then we're also going to hide
our headers. Now this point going to jump
back in really quick to X. I just show
you this is where our technique differs
a little bit from Bora Berans.
Boras technique well really advanced and
really helpful didn't allow you to use
Tableaus built-in coloring. You had to go
in and manually color things yourself
So for ours we added in the additional
dimensions right here. And then we had to
address those inside of our table
calculations. But when we did that we
actually could come in and rather than
these being a detail we can change them
to color. And then you can do the
multiple color technique to keep adding
them in. And then you get this nice color
gradient across your four different
dimensions. That were really helpful. This
makes it so that we have to have all
four of them inside of our table
calculations and makes her a bit more
clicking and a memorizing of a silly
pattern - Region, Segment, Product Category
Brand. When you're applying this to your
own charts make sure that you have the
kind of steps down your dimensions that
you want to have happened. Your different
levels from Region, Segment, Product
Category, Brand or whatever your four are
and you comprehend that because you're
going to have to manually code those
into your table calculations. This
doesn't make it more prone to break as
well so it's not necessarily the best
fix in the world. But for us it was worth
it so we could get that coloring that we
really like. At this point our chart is
coming together really nicely.
You can see it on your view right now
We've got our four Regions and then we
also have our Segments our Product
Categories and our Brands underneath
that. Coming in we're going to do a
couple more cosmetic changes. Make our
Tooltip a little bit nicer adding some
borders and then add things to a
dashboard. So your chart will be a bit
more readable for your users. And
hopefully will be a better experience
for them. Coming in the next step we're
going to do is add in that border that
we were talking about you can even make
it a dark border or a light border for
the more modern theme we'll stick with
the lighter color. And then coming into
our Tooltip at the moment you can see
the
we have a whole bunch of information.
Everything that's in the view. And somebody
we honestly don't need. For instance
Padded is it useful for us as we build
the chart but not for the end-user. And
the X and Y coordinates well interesting
are not what's needed as well. So we're
gonna come into our Tooltip remove
those fields that we don't need. Also
going to get rid of Level and that one's
kind of visually self-explanatory. Then
we'll come up Region in Segments I'll
put these in. And then we'll move Product
Category keeping with our favorite
pattern of four dimensions that we have
beaten into the ground and into our
memories by now. So now as you hover over
you'll see that we have our Region we
have the Product the Segment, then we
have the Product Category then the Brand.
Now there's arguments that you could do
different ways you could have it just
show exactly what the Region is or the
Segment is a Product Category. For me I
like seeing the steps going down the
view. Being able to see exactly where
your chart is coming from or what each
individual mark means. This is just kind
of a personal preference you're welcome
to do whatever you'd like with it.
Now that we have a Tooltip ready and we've
added in our borders we are ready to
rename this we have our Sunburst Chart.
Then what we're going to do is we're
going to create a value that shows the
actual individual sales. So come here
we'll add MaSales -  the text. Will make
this an entire view then we'll come up
here and we'll add a little bit of a
label. I just double clicked in there
then we'll call this Sales. Do that. What
we have right here is just a simple text
field but it actually the shortcut for
creating your own header. So if we come
down and we hide the field label for
that, coming in format this so it's going
to show up on a dashboard we know we
need to make it a little bit bigger 20
is probably good, make it bold and then
for sales we'll want to format that as
well and let make it currency. Data set
was in USD. And then we'll drop the
decimal points because we don't need
them. Now that we have that we'll call
this our SalesLabel. We can create our
dashboard so this one you can use
whatever size you use web page embedded
tends to look best, but we'll bring out
our Sunburst Chart.
We'll get rid of the legend because we
don't need that at the moment. And then
what we'll do is for SalesLabel rather
than bring it as titled we'll bring it
in as a floating. And drag it to the
center of our chart. We'll hide the title
then we'll resize it just a little bit.
Now that we finish sizing we have our
Sunburst Chart we have our Sales ready
but I also want to come in and add a
legend.
So looking at our Sunburst Chart we
do have a legend but it's a little bit
clunky. You've got every single value
every single combination it's too long
to be able to see in one go. And you have
a lot of null values so it'd be nice if
we create a legend that just shows the
Region. Because those are kind of the
dominant colors in our view. So if we
come here we'll call this legend for
being Region up to color; drag that up two
rows. We now have what looks like a
legend. We can come in will notice that
North is orange South is green East is
blue West is yellow. We can then come in
say North is orange
South is green East is blue West is
yellow it's just matching when we had
And then we'll reorder this kind of the
best practice to go along with people
expect so North South East West is it
usual way in English to describe the
cardinal directions. So we have those for
our legend. We can bring our legend in
as a floating object. We'll hide the
title, hide the redundant legend from our
legend sheet. And then we can shrink this,
bring it down here out the corner and we now
have a great little legend that explains
the view that's going on. Now the final
touch will want to come into a dashboard
right here and add an action. We're going
to add a filter action, call this our
Sales filter, because we wanted to apply
from our Sunburst Chart and only go down
to our Sales. We're going to make it act
on a hover I'm going to changes to
exclude all values and then we wanted to
filter according to the dimensions that
are in our Sunburst Chart. So for the
last time we have Region Segment
Product Category and Brand. Once we have
that built we can now hover over each
individual mark and the sales will
adjust it shows what we need. So now we
have our West region we can tell there
was 108 thousand in sales. We have our
South Region for grocery and the
vegetable sales there was 22,000 in
sales and so on and so forth. The reason
we went into our actions right here and
we chose exclude rather than show all
values is because unfortunately the
window max function doesn't quite
comprehend everything like we need it to.
The window max function in fact will
return this hundred fifteen thousand for
the maximum region rather than the
entire sum of the data set. So if anybody
watching this can figure out a way to
fix that we love that and we appreciate
seeing in the comments below. But at this
point we now have our Sunburst Dashboard
we can come in and we can edit this at
our Sunburst Sales Dashboard. And you
know how the full functionality to come in.
You have your Regions -  North, South, East
and West.
You have the descending dimensions that
we're looking for. And you have the
individual sales values that show up as
your customers interact with the data. So
hopefully this is helpful. Hopefully
you're able to follow all the steps this
is definitely a very advanced chart type
so well done keeping up and moving along
with this. Feel free to send us feedback
on superdatascience.com and we'll see
you on our next tutorial series.
Thank you!
