DAX Parent-Child Hierarchy Path Measure

Builds a readable path string (e.g. "CEO > VP > Manager") through a self-referencing parent-child hierarchy.

Advanced PatternsAdvancedparent-childhierarchypath

DAX code

Hierarchy Path =
PATH('Employee'[EmployeeID], 'Employee'[ManagerID])

Hierarchy Path (Names) =
VAR IDPath = PATH('Employee'[EmployeeID], 'Employee'[ManagerID])
RETURN
    CONCATENATEX(
        GENERATESERIES(1, PATHLENGTH(IDPath)),
        LOOKUPVALUE('Employee'[Name], 'Employee'[EmployeeID], VALUE(PATHITEM(IDPath, [Value]))),
        " > "
    )

Notes

PATH requires the parent-child columns to be on the same table; use Power BI's built-in Parent-Child hierarchy converter for deeper trees if this gets slow.

Requirements

How to use this measure

  1. In Power BI Desktop, select the table that should hold the measure and choose New measure on the ribbon.
  2. Paste the code, then replace the placeholder table and column names with your own. The My table names fields above do this for you.
  3. Run it through the DAX Formatter if you want it laid out in your team's style.

More DAX resources

Browse all 175 measures in the Power BI DAX Measures Library, or search the library for something similar to Parent-Child Hierarchy Path.