Microsoft Power BI Complete Reference
上QQ阅读APP看书,第一时间看更新

Creating hierarchies

Predefining hierarchies can provide several key benefits. Some of those benefits are listed here:

  1. Hierarchies organize attributes and show relationships in the data
  2. Hierarchies allow for easy drag and drop interactivity
  3. Hierarchies add significant analytical value to the visualization layer through drilling down and rolling up data, as necessary

Hierarchies store information about relationships in the data, that users may not have otherwise known. I remember when I was working for a client in the telecommunication industry and they had Base Transceiver Stations (BTS) and Sectors, and without looking at my notes, I could never remember the correct order. Did a BTS contain multiple sectors, or did a sector contain multiple base transceiver stations? Once the hierarchy was added to the data model, I no longer had to worry about remembering the relationship because the relationship was stored in the hierarchy. Here is a list of common hierarchies:

  1. Category | Subcategory | Product
  2. Country | State | City
  3. Year | Quarter | Month | Day

Hierarchies may only be created in either the report or data view. In order to create a new hierarchy, complete the following steps:

  1. Expand the Sales Territory table.
  2. Right-click on the Sales Territory Country column.
  3. Select New Hierarchy:
Figure 30-Create a new hierarchy

A new hierarchy has been created with a single column, and given a default name of Sales Territory Country Hierarchy:

Figure 31-New hierarchy created

First, right-click on the Sales Territory Country Hierarchy and rename it to Sales Territory Drilldown. The next step is to add additional columns/attributes to the hierarchy. Complete the following steps:

  1. Right click on Sales Territory Region.
  2. Click on Add to Hierarchy.
  3. Select Sales Territory Drilldown.
  4. Repeat steps 1-3 for Sales Territory Group:
Figure 32-Adding columns/attributes to the hierarchy

The completed hierarchy can be seen in the following screenshot. However, the order of the attributes is incorrect; the order should be Sales Territory Group | Sales Territory Country | Sales Territory Region:

Figure 33-Completed hierarchy

To correct the order of the attributes:

  1. Right-click on Sales Territory Group.
  2. Click Move Up.
  3. Repeat steps 1 and 2:
Figure 34-Correct the order of attributes