Azure Analysis Services Documentation

Modeling Hierarchies in Azure Analysis Services

Hierarchies represent business relationships between data in your tabular model. They allow users to navigate through different levels of detail, providing a more intuitive and user-friendly analysis experience. Common examples include date hierarchies (Year > Quarter > Month > Day) or organizational hierarchies (Country > State > City).

Why Use Hierarchies?

Creating Hierarchies

Hierarchies can be created using either Visual Studio with SQL Server Data Tools (SSDT) or SQL Server Management Studio (SSMS).

Using Visual Studio (SSDT)

  1. Open your Azure Analysis Services tabular model project in Visual Studio.
  2. In the Model Designer, right-click on the table containing the column(s) you want to use for the hierarchy.
  3. Select "Create Hierarchy".
  4. Choose a name for your hierarchy (e.g., "DimDateHierarchy", "ProductHierarchy").
  5. Drag and drop the columns that define the levels of your hierarchy from the "Fields" pane to the new hierarchy pane. Ensure the order of the columns reflects the desired drill-down path.
  6. You can create both standard hierarchies and parent-child hierarchies.

Using SQL Server Management Studio (SSMS)

  1. Connect to your Azure Analysis Services instance using SSMS.
  2. Navigate to your database, then to the "Tables" folder.
  3. Right-click on the table where you want to create a hierarchy.
  4. Select "New Hierarchy".
  5. Enter a name for the hierarchy.
  6. Drag columns from the table's column list to the hierarchy designer.

Types of Hierarchies

Standard Hierarchies

These are the most common type, where each level is based on a distinct column. For example, a "Date" hierarchy might have columns for Year, Quarter, Month, and Day.

Example Structure:


Year
  Quarter
    Month
      Day
            

Parent-Child Hierarchies

Parent-child hierarchies are used when you have a self-referencing relationship within a single table. A common example is an employee table where each employee has a manager, and managers are also employees. This requires two columns:

Azure Analysis Services automatically determines the relationships and levels based on these two columns.

Tip: Parent-child hierarchies are powerful for representing organizational structures, skill trees, or any recursive data relationships. Ensure your data has a single root node (a member with no parent) for proper hierarchy formation.

Hierarchy Properties

When creating or editing a hierarchy, you can configure several properties:

Working with Hierarchies in Reporting Tools

Once published, hierarchies appear in reporting tools like Power BI, Excel, or Tableau, allowing users to easily navigate through the data:

Best Practices