Construct a Treemap in Tableau with Chosen Ranges of Element
Earlier this month I wrote a weblog put up about Using Treemaps to Visualize Data the place I clarify how and when a treemap could be helpful in information visualization. Final week Andy Kriebel posted a Exercise Wednesday problem to Highlight a Treemap, which demonstrates three totally different strategies to focus on a phase in a treemap. This put up will reveal how one can change the extent of element that the treemap makes use of and even use totally different ranges of element inside the nodes of the treemap.
Constructing a treemap
Like my pal Andy, I hardly ever use the Present Me in Tableau. I reveal it in coaching classes, however I do not discover it helpful day-to-day. Andy used the Present Me to create his treemap for his weblog put up, so let’s begin by constructing one with out the Present Me.
The treemap is an odd chart to create in Tableau. Why? As a result of it doesn’t have a capsule on the Rows or Columns. Every part is finished on the Marks Card. Even so, the chart may be very easy to construct. For this demonstration I will likely be utilizing the World Indicators information set that’s a part of Tableau Desktop.
Construct a treemap:
Open Tableau and choose the « World Indicators » information
Transfer Area to Coloration
Transfer Nation to Particulars
Transfer Inhabitants Complete to Measurement and alter the Measure to SUM
Add 12 months to Filters and choose 2012 (it will filter the info to a single yr)
You now have a fundamental treemap. You’ll be able to transfer Nation to Label if you need to have the international locations listed within the treemap and you’ll add different fields to the Label, for instance, I added the Inhabitants Complete.
That was straightforward! It is necessary to grasp what is going on although. No matter stage of element is within the marks card is the extent that may cut up the treemap. If Area(colour) and Nation(Particulars or Label) are each on the Marks Card then the treemap will present each ranges within the treemap utilizing that hierachy. No matter subject is on prime would be the main cut up and so forth. If Nation is eliminated then the treemap will solely present Areas with out a cut up on Nation. Now we’ll add some performance to it so we are able to select numerous ranges of element.
Constructing the Stage of Element
Step one to create totally different ranges within the treemap is to create a parameter.
Step 1: Create a brand new parameter
Parameter Title: Choose Area
Information Kind: String
Allowable Values: Checklist
Choose Add from Area and choose Area
As soon as the values for the Areas are crammed in, add All and None to the record.
Proper-click on the brand new parameter and choose Present Parameter.
Step 2: Create Calculated Area
Calculated Area Title: Element Stage
if [Select Region] = [Region] then [Country]
elseif [Select Region] = ‘All’ then [Country]
Step 3: Use the New subject Element Stage rather than Nation
This new capsule will now be used rather than Nation. Simply drag the brand new subject on prime of the Nation capsule. When a Area is chosen from the brand new parameter, the extent of element will now be chosen. Let’s study what the calculation is doing.
If All is chosen then it is going to be on the lowest stage of element – Nation.
If None is chosen then it is going to be on the highest stage of element – Area.
If any of the Areas are individually chosen then it can use the Nation for that choice and Area for every little thing else.
This parameter now permits the person to pick totally different ranges within the treemap to create totally different comparisons. For instance, when choosing « Asia » from the record, it is easy to check the Nation of India to the Area of Africa, which is now displayed as a single Area as a substitute of International locations. As well as, placing the Sum of the Complete Inhabitants on the Label will sum the Inhabitants on the totally different ranges being aggregated (Area and Nation). Click on the picture under to enlarge.
This strategy presents extra comparisons for the person. As I outlined in my earlier weblog put up about Using Treemaps to Visualize Data, when there are small numbers of classes, ex. there are solely six Areas, a bar chart is sort of all the time higher. Nevertheless, as analysis has proven, a treemap presents higher accuracy for leaf to non-leaf comparisons. By including this performance, the person can now shortly create their very own leaf to non-leaf comparability on the desired stage of element. You’ll be able to download an example Tableau workbook here.
I hope you discover this info useful. In case you have any questions be happy to electronic mail me at Jeff@DataPlusScience.com
Jeffrey A. Shaffer
Comply with on Twitter @HighVizAbility