Hierarchies are quite special. They regroup multiple Dimensions. However, a Hierarchy doesn't just affect the Data Source, but also the visualization and the way the users can interact with it. A hierarchy creates a relationship between different Dimensions, such as a parent-child relationship.
The dedicated icon for Hierarchies is .
Dates, for example, are a hierarchy. A day is included in a week, which is included in a month and a year. If you use a Date in a Worksheet, such as Order Date, Tableau automatically selects the YEAR and shows a small + in the pill, at the left of the name. It means that the Dimension is a parent in a hierarchy and there are children. This is illustrated in the following screenshot:
Once you click on the +, the child is added next to the parent, and the + switched to a - to remove the child. The child can also be a parent of another Dimension, and so on. You can see, in the following screenshot, where the YEAR of Order Date is a parent of the QUARTER, and the QUARTER is a parent of another dimension:
Enough for the theory, let's create a hierarchy and use it. You can reproduce the following example with the Sample - Superstore dataset:
- Select the Dimensions you want to combine in a Hierarchy. For this example, select Category and Sub-Category.
- Right-click on one of the selected Dimensions and go to Hierarchy, then Create Hierarchy...:
- A new window opens asking for the name of the Hierarchy. Let's name it Products.
- The Hierarchy is created, and you should see a new icon in your Data pane, with the Category and Sub-Category (in that order) under it. Your Hierarchy should look similar to the following screenshot:
- Let's add the Product Name in the Hierarchy, at the last position. To do that, you can drag and drop the field under Sub-Category:
- Double-click on Category, then on Profit. It creates a simple table. You can see the + next to the Category pill. You can also see the +, when you hover over the values in the visualization:
- Click on +. Tableau automatically adds the child, Sub-Category. From here, you can go deeper with + or remove Sub-Category with -. Here's the final result:
Hierarchies are a useful and powerful tool. Use them when you can! Let's finish this chapter with the last option: creating Groups, Sets, and Bins.