[This post is long over due. The Super Pi Day reminds me of it and thus this Pie Chart post is dedicated to the Day!]

[A sequel has been written on Grouping Lower % Bars in Bar Chart It explains the calculation from a slightly different perspective.]

A post of couple of months old in Tableau Forum has re-surfaced thanks to Patrick Van Der Hyde's effort, asking how to group lower % slices into a single one in a pie chart.

Having worked on a similar project grouping lower ranked slices before, I thought this is easy. This time, it's about grouping lower % slices. And it takes a few more steps.

The purpose in this example is to use pie chart to view the top % countries in terms of sales and group the lower % slices into one. Let's get started.

Build the Pie

1.Select the Pie chart type and make the working canvas Entire View.
2.Create a parameter [N% Chooser] which allows us to choose any % as threshold. One can skip this if the percentage is a given number.
3.Drag the [Country/Region] to the Detail shelf. Right click it and sort it by Sum([Sales]) descendingly.
4.Create a new field [Top % + Others Label] which labels all low % slices as "Others". Drag it to the Color shelf. Note that the percentage is dynamically controlled by the parameter 0.01*[N% Chooser]. One replace it by a given number if necessary.
5.Create a new field [Top % + Others Sales] which sums up the sales of all Others into one value. We will explain the logic later. For now, drag it to the Angle shelf. Right click the pill and select Compute Using>Country/Region.

Now we have a barebone pie chart that groups the lower % !

Dress up

We need to add labels to the pie.

- Drag [Top % + Others Label] to the Label shelf.
We see that there are more than one slices labeled as Others. We only need one label and need to filter the rest.
- Drag [Top % + Others Sales] to the Filter shelf. When prompted with filter settings, click OK.

- Right click the filter pill and select Compute Using>Country/Region. When filter settings pops up again, click Special tab and select Non-null values.
- Create [Percent] field and drag it to the Label shelf. Right click on it and select Format to make the numbers in %.
  • [Top % + Others Sales]/Total(Sum([Sales]))
Now we are essentially done. Further cleanup is recommended:
- Click the Size shelf and adjust the size of the pie.

- Create a [Blank] field with "" and drag it to both Row and Column shelves. Then right click it and uncheck Show Header. This will remove the headers and leave the canvas clean.

- Right click the canvas and select Format. Go the grid menu and turn Row Divider to None. This will remove some unnecessary horizontal lines.

Now we have a perfect pie chart that groups the lower % slices into one, dynamically with the parameter! The workbook is here.

Calculating [Top % + Others Sales] and Filtering

The calculation is as follows:

if [Top % + Others Labels]="Others"
then if Last()=0
     then Window_Sum(if [Top % + Others Labels]="Others" then Sum([Sales]) end)
     end
else SUM( [Sales] )
end

It shows that, for the new label "Others", we need a different calculation. Otherwise it's just Sum([Sales]).

Widow_Sum() will only take into account the sales of those labeled with "Others".

There are likely multiple slices labeled as "Others". We only need one. Last()=0 will do that. The sales figures for the rest will be Null. This will be used in the filter to exclude them.

PS. Pie chart has met with great resistance in the visualization community. One of the problems is that it looks messy and cluttered when there are too many slices. Still, people are attracted to circle shapes more than others. Hope this tutorial will help creating a cleaner and more appealing pie chart and relieve the pain at the viewer side.

0

Add a comment

(Refresh the page if you want to view the gif image multiple times. Or go to Tableau Public and click the button at the top-right corner.)

Jake and I collaborated on a dashboard. He told me that he learnt a way to create an in-place help page in Tableau. He first saw it at a conference somewhere and couldn't recall who the speaker was. So I am blogging here about it but the credit goes to somebody else. If anyone knows who the original creator is, leave a comment below.

The key idea is to float a semi transparent worksheet on top of the dashboard, where a help text box is strategically placed on top of each chart. This way, we can explain how to view each chart and what data points are important, etc. This worksheet is collapsible by a show/hide button. 

Below I would like to show how this worksheet can be constructed.

1. Sheet with a single data mark.

  • Double click the empty space in Marks panel and add two single quotes. Make the null pill a text label. This creates a single null mark.
  • Set the view as "Entire View"

2. Create an show/hide button

  • Go to the target dashboard
  • Drag a floating vertical container to the dashboard, making it cover all the area of interest.
  • Drag the Single Null Mark sheet and drop it into the above container. Hide the sheet title.
  • Create an open/close button for the container and place the button at the top-right corner.

3. Add annotations

  • Format the sheet background opacity as 70% in the layout manager             
  • Select area annotations and place them anywhere of interest. 
  • Write help text and format it to highlight important messages.  
  • The text can serve as functional guide and/or insight guide.

Here is an example. Feel free to download the workbook and explore. Click the "i" button at the top-right corner to view the in-place help. 

0

Add a comment

Blog Archive
Loading
Dynamic Views theme. Powered by Blogger. Report Abuse.