Microsoft Certified: Power BI Data Analyst AssociateModel the dataHard

A data analyst is building a Power BI model to track employee performance. The model includes an 'Employees' table (EmployeeID, ManagerID, EmployeeName) and a 'Sales' table (EmployeeID, SalesAmount). The 'Employees' table has a self-referencing relationship where 'ManagerID' links to 'EmployeeID' to represent the organizational hierarchy. The analyst needs to create a measure that calculates the 'Total Sales' for an employee and all their direct and indirect subordinates. Which DAX function is essential for traversing this hierarchy to sum sales?

  1. APATH()
  2. BRELATEDTABLE()
  3. CSUMX()
  4. DPATHITEM()
Show answer & explanation

Correct answer: A. PATH()

The PATH function is essential for traversing parent-child hierarchies in DAX. It generates a delimited text string containing all the identifiers of the parents working up to the root from a given child. This string can then be used with other functions like PATHCONTAINS or PATHITEM to filter or retrieve specific levels in the hierarchy, allowing for calculations that aggregate values up or down the organizational structure, such as summing sales for an employee and all their subordinates.

Why the other options are wrong

  • B. RELATEDTABLE retrieves a table of rows related to the current row in a one-to-many relationship, but it doesn't traverse multiple levels of a hierarchy.
  • C. SUMX is an iterator function that sums an expression over a table. While it's used in the final aggregation, it doesn't itself traverse a hierarchy.
  • D. PATHITEM retrieves an item at a specific position from a path string generated by the PATH function, but it doesn't generate the path or perform the traversal directly.

DAX Parent-Child Hierarchy Functions

DAX provides a set of functions (PATH, PATHITEM, PATHITEMREVERSE, PATHCONTAINS) specifically designed to work with parent-child hierarchies, allowing for dynamic traversal and aggregation of data across hierarchical levels.

  • PATH creates a delimited text string of parent IDs.
  • Requires a self-referencing relationship in the dimension table.
  • Used with PATHCONTAINS to filter for descendants/ancestors.
  • Enables calculations like 'sales by manager and their team'.
  • Crucial for organizational, product, or geographical hierarchies.

Memory trick: For hierarchies, PATH finds the way, then CALCULATE sums the day.

More Model the data questions