Power QueryExercises

Count each employee's levels of management with recursion (hospital)

Each employee row names its manager (or null at the top). Compute how many managers sit above each person.

Level
advanced
Time
~14 min
Task
Build the query
Access
Pro
Checking your access…

About this exercise

What you'll practise

Write a recursive function over a parent–child table.

The scenario, sample data, step list, hints and solution open with Pro. Grading checks your query against hidden data as well as the visible sample, so a query that only fits the sample doesn't pass.

Input

  • Roster (table)
    • EmpID: text
    • FirstName: text
    • LastName: text
    • Department: text
    • City: text
    • Salary: number
    • StartDate: text
    • Manager: text (nullable)
    • Email: text

Expected output columns

EmpID (text), Manager (text (some rows null)), Levels (number)