Introduction to Hierarchy in Tableau
The hierarchy in Tableau is an arrangement where entities are presented at various levels. So, there’s an entity or dimension under which there are further entities present as levels. In Tableau, we can create hierarchies by bringing one dimension as a level under the principle dimension. The main dimension is the one over which we create the hierarchy. When it comes to analysis, the concept of hierarchies proves handy, as we don’t have to bring all the dimensions separately into analysis. Having meaningful hierarchies in the analysis is thus useful as we can expand from and contract to the main dimension as needed.
Creating and Removing Hierarchies in Tableau
In the following section, we shall see how to create, use and remove hierarchies. Before creating hierarchies it must be ensured that the intended hierarchies are meaningful in nature. For this demonstration, we are using the Distribution Unit Volume dataset. The dataset contains volume distributed for a product by distribution units. Important dimensions in the dataset are Region, Distribution Unit, City, DU Code, and Mode while Distribution Volume is the measure.
Here we’ll define a hierarchy for geographical dimensions which are Region, Distribution Unit, and City. Region is the largest unit followed by the Distribution Unit which is followed by City. The city has been represented in the form of codes.
Creating Hierarchy
Let’s proceed to understand how to create hierarchies in Tableau in order to accomplish the above task.
1. First, load the dataset into Tableau. For that click on “New Data Source” under the Data tab. Alternatively, click on “Connect to Data”.
2. In the section that pops-up, select the requisite data source type. In this case, it is MS Excel, so we selected Microsoft Excel.
3. We can visualize the loaded data in the “Data Source” tab. Examine the data prior to proceeding to analysis. The data must be intact for correct results.
4. Moving to the sheet tab, we can find the dimensions and the measure present in the requisite sections.
5. We want to create Region -> Distribution Unit -> City hierarchy. In order to create this hierarchy, click on the drop-down menu of the Region dimension. From the menu, in the “Hierarchy” option, click on the “Create Hierarchy” option.
4.5 (9,707 ratings)
₹7999
View Course
6. Following the above procedure generates a simple dialogue box for naming the hierarchy. We will name it as Region which is as shown as follows. Once naming is done, click on Ok.
7. The newly created hierarchy appears under Region dimension as can be seen in the below image. Note, now there exists only one level which is nothing but the one represented by the dimension over which the hierarchy has been created.
8. The next level in the intended hierarchy is the Distribution Unit. So, we need to add this dimension to the next level. For that, in the drop-down menu of the dimension “Distribution Unit”, click on the “Hierarchy” option. Now, here, two options will appear viz. “Add to Hierarchy” and “Create Hierarchy”. We have already created a hierarchy into which we just want to add the dimension Distribution Unit. So, in the “Hierarchy” option, click on “Add to Hierarchy”, and select “Region”.
9. The above steps lead to the creation of the second level in the hierarchy Region. This is as shown by the following image.
10. Now, following the same procedure as described in the preceding part, we shall add City dimension as the third level in the hierarchy as shown below.
11. The above steps lead to the creation of the third level in the hierarchy which is City as highlighted below.
12. Now that hierarchies have been created, we shall use them in analysis. Drag the Region dimension over which hierarchies were created into Columns Region and measure Sales in Row. We get the following vertical graph.
13. The following image gives a closer look into Region dimension which contains hierarchies. Notice, a plus symbol appears which means the dimension contains hierarchies. In order to expand the hierarchies, click on the plus symbol.
14. For better analysis, we will convert the vertical graph into a horizontal one as shown in the below image.
15. When we click on the plus symbol in the Region dimension, the next level appears which, in this case, is the “Distribution Unit”. Now, note that Region has expanded to the next level, so minus appears before the Region dimension, while for level Distribution Unit plus appears, which means that more level(s) is(are) are there.
16. Now, as shown in the following image, we first expanded the Distribution Unit level and minus now appears for it. The next level that gets generated is City. Note, for City, there’s no sign either positive or negative, which means that no further level exists. All the three levels in the defined order are there in the Rows region. When we dragged the Distribution Unit over Color in Marks Card, we can see that City got dragged automatically over the Detail section in the Marks Card. This is because of the hierarchy.
17. The Following screenshot gives us a closer look into the application of hierarchy.
Removing Hierarchy
18. Now, it is important to note that once the analysis is done or requisite insights have been obtained, it is always good to have the hierarchies removed. How we can accomplish that, let’s see. Remove the hierarchy in order, so, click on the drop-down menu of City, then in “Hierarchy” click on “Remove from Hierarchy”. This has been illustrated in the below screenshot.
19. In the below screenshot we can see that City dimension no more appears in the Region hierarchy.
20. Following the same steps as above, remove the dimension “Distribution Unit” from the hierarchy.
21. Similarly, we remove Region dimension too over which only we had created the hierarchy. Note that the analysis remains intact. This is because the hierarchy has been removed and not the dimensions. And this is shown by the disappearance of the plus and minus symbols from the dimensions in the Rows region.
Conclusion
Having hierarchies containing the desired number of levels representing requisite dimensions is always helpful. Hierarchies are a very powerful tool as they enable strong view-level analysis without actually affecting the original dataset. In Tableau, using hierarchies, one can drill-down data as needed. This proves quite useful especially in situations involving complex problems.
-===============================
Create Hierarchies
When you connect to a data source, Tableau automatically separates date fields into hierarchies so you can easily break down the viz. You can also create your own custom hierarchies. For example, if you have a set of fields named Region, State, and County, you can create a hierarchy from these fields so that you can quickly drill down between levels in the viz.
Watch a video: To see related concepts demonstrated in Tableau, watch Drill Down and Hierarchies, a 5-minute free training video. Use your tableau.com account to sign in.
To create a hierarchy:
In the Data pane, drag a field and drop it directly on top of another field.
Note: When you want to create a hierarchy from a field inside a folder, right-click (control-click on a Mac) the field and then select Create Hierarchy.
When prompted, enter a name for the hierarchy and click OK.
Drag additional fields into the hierarchy as needed. You can also re-order fields in the hierarchy by dragging them to a new position.
When you add a field from a hierarchy to the visualization, you can quickly drill up or down in the hierarchy to add or subtract more levels of detail.
To drill up or down in a hierarchy in Tableau Desktop or in web authoring:
In the visualization, click the + or - icon on the hierarchy field.
When you are editing or viewing the visualization on the web, you have the option of clicking the + or - icon next to a field label.
To remove a hierarchy:
In the Data pane, right-click (control-click on a Mac) the hierarchy and select Remove Hierarchy.
The fields in the hierarchy are removed from the hierarchy and the hierarchy disappears from the Data pane.
No comments:
Post a Comment