top of page
Search

# Let’s bake some scrumptious versatile pies ... part 1

What is pie chart?

· A pie chart is type of chart in which a circle is divided into sections to represent numerical proportion. It can be used to show percentages of a whole.

· The arc length of each section is proportional to the quantity it represents.

· It resembles a pie that’s sliced and there are various ways in which it can be represented.

What are the various forms of pie Chart?

Ø Donut chart

Ø Drill down or extended donut/ pie chart

Ø Semi donut Chart

Ø Sunburst / multi- level pie chart/ radial tree map

Ø Square chart/ Waffle chart

Ø Coxcomb chart /Rose chart/ Polar Area Chart

Let’s first start by making a pie chart in Tableau.

To make a pie chart we need one dimension and one measure. I will be using Superstore data to look at category wise sales. We can create a pie chart either by dragging category to columns and sales to rows then click show me and select pie chart. By doing so category will be moved to colors and sales will be moved to angel. Or we can make a pie chart by directly selecting pie under marks card and put category into color and sales to angle. Now we can add category and sales (sum) to label.

Image by author

Donut Chart:

What is donut chart and where is it be used?

A donut chart is basically a pie chart with its center cut, it resembles a donut and hence the name.

It shows the proportions of the categorical data where the size of the sections represents the proportion of categorical data, multiple data sets can be displayed at a time and are good for comparing data sets.

To create a donut chart double- click on rows and type avg (0) a field AGG(avg(0)) is created as shown below:

Image by author

As we need two measures, we recreate this field.

Image by author

By doing so now we have two marks card:

Image by author

Marks card (1): change the mark type from automatic to Pie chart & then move dimension i.e., Category to color and measure i.e., sales to angle. Change the view from standard to entire view and adjust the size of the pie.

Image by author

Now drag and drop category and sales to label.

Image by author

Marks card (2): change the mark type from automatic to Circle chart and use the color and size cards to adjust the color and size of the circle. Change the color to white, add a border to it and decrease the size of the circle. Once again move sales to labels.

Image by author

To get a donut chart, right- click on the second field avg(o)and select dual-axis.

Image by author

Select the total sales label and drag it inside the circle and format it.

Image by author

Moving on to the next one...

Drill down or extended donut chart:

For this we must create parameters to drill down categories to subcategories.

Let’s create a parameter by right clicking Category and select create parameter.

Image by author

Now type the name as Targeted or Focus category as it will show sub-categories for the selected category for example if I select technology then it will show sub-categories for this category only. In the list we have all 3 values listed for this dimensions but I need one more dimension so that when none of the values are selected it should reset .

This can be done by clicking the ‘click to add’ and type in Reset and then click ok.

Image by author

By doing so we have created a Focus category parameter. Now we have to make sure that only when a category is selected we can see its sub-category, for this we need to create a calculated field. Again right click category, select create calculated field. Let us name it as category filter and type in focus category = category and the click ok by doing so we are creating Boolean ( i.e., either True or False value).

Image by author

We need to create a color legend by creating a calculated field, for which we can convert Boolean filter to string. This filter is for creating color legends for the subcategory dimension. Type in STR(category filter) + (category) and click ok .

Image by author

STR() converts (category field ) into a string. Now we have 2 filters now.

Image by author

We need 2 more fields:

1. Sub-category label

2. Sub-category text label

Again we need to create calculated field.

Image by author

Select calculated field and name it as Sub-category label and type as shown above. So that sum of sales are displayed only when its true and Boolean fields can be concatenated as t for true and f for false. Once we click ok a sub-category label is created.

We have to create one more calculated field and name it as Sub-category Text Label and type as shown in the fig below and click ok.

Image by author

Now all we have to do is create the view. Let’s see how it is done.

Firstly, remove Category from color and add Category color filter instead. By doing so we can see that which ever category is selected, it will be shown as true only for that one and rest all will be shown as false. In this case it is furniture as it is the focus parameter.

Image by author

We have to change the color palette according and select each option manually to see the corresponding sub-categories getting displayed. When the Boolean is true we keep the color and for false we change it to white so that it will remain hidden.

Right Click on Focus parameter and then click show parameter by doing so focus parameter gets displayed on the right hand side.

Image by author

Click the drop-down option for Category color filter, select edit colors then double click on technology and change the color to white. Similarly change the color for office supplies also. We have to change the color palette for Technology to lighter shades for sub-category.

Image by author

And this how it will looks..

Image by author

Similarly we have to do for the others . Select Technology in Focus Category and change the colors. Finally select office supplies and do the same.

Image by author

Image by author

Note: Please make sure that the order of alignment in focus category is the same or else it won't work.

We need to do few more changes go to all under marks card and select white border and got to pie and add Category and sub-category to details and the two new fields that is Sub-category text label and sub-category label to labels , format sales to Currency custom with zero decimals.

Next we have to create a dash board -floating and drag the donut chart to the dash board. Format sales to percent of total.

Image by author

Now we have to edit the tool tip in the donut chart under All in marks card and change it to

<Category>

< Sum of sales>.

Make sure the shading for worksheet is selected as none.

Image by author

Next bring the drill down chart ,hide the title and remove focus category and category color filter. Let the alignment of floating be bring to front, now all we have to do is drag and arrange the two charts in such away that

that sub-category appears to extend from category.

Image by author

Lastly we have to set parameter actions so that we can achieve the above view for each category as we hover the curser. For that go to dashboard and select actions then click add actions then select change parameter.

Image by author

Make the following changes as shown below and click ok.

Image by author

Now check the alignment of the two graphs by using slide show . If required change the size of the circle so that proper alignment is achieved.

image by author