Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
BBHouston
Helper I
Helper I

How to create a supervisor hierarchy table:

Let's say I have a table that looks like this:

 

Staff NameSupervisor
Ryan*blank*
MarthaRyan
EricaRyan
DavidMartha
SamanthaErica
KyleErica

 

How do I build a table or table visual that looks like this? 

Lv. 1Lv. 2Lv. 3
RyanEricaSamantha
  Kyle
 MarthaRyan



 

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @BBHouston 

You  also can try  a solution in Dax.

Path = PATH('Dax'[Staff Name],'Dax'[Supervisor])
Level1 = PATHITEM('Dax'[Path],1)
Level2 = PATHITEM('Dax'[Path],2)
Level3 = PATHITEM('Dax'[Path],3)

 67.png

Best Regards,
Community Support Team _ Eason

View solution in original post

4 REPLIES 4
v-easonf-msft
Community Support
Community Support

Hi, @BBHouston 

You  also can try  a solution in Dax.

Path = PATH('Dax'[Staff Name],'Dax'[Supervisor])
Level1 = PATHITEM('Dax'[Path],1)
Level2 = PATHITEM('Dax'[Path],2)
Level3 = PATHITEM('Dax'[Path],3)

 67.png

Best Regards,
Community Support Team _ Eason

@v-easonf-msft Thank you!!! This solution ended up being the simplest and working the best for me. 

mahoneypat
Microsoft Employee
Microsoft Employee

Please see this article on how to use the PATH function to do this.

On the Right PATH() - A DAX/Power Query approach to working with parent/child hierarchies. - P3 (pow...

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


CNENFRNL
Community Champion
Community Champion

Hi, @BBHouston , you might want to try a solution in Power Query

let

    Path = (emp) as text => 
        let
            sup = suplist{List.PositionOf(emplist, emp, Occurrence.First)},
            recursion = if List.PositionOf(emplist, sup) = -1 then "" else @Path(sup) & "|" & sup
        in
            recursion,

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCqpMzFPSUVKK1YlW8k0sKslIBPLAgiAR16LMZBQBl8SyzBSgAFQpSCg4MTcxD6IPohwk6F2Zk4oQiAUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Staff Name" = _t, Supervisor = _t]),
    emplist = List.Buffer(Source[Staff Name]),
    suplist = List.Buffer(Source[Supervisor]),

    #"Added Hierarchy" = Table.AddColumn(Source, "Lv", each Path([Staff Name]) & "|" & [Staff Name]),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Added Hierarchy", "Lv", Splitter.SplitTextByDelimiter("|", QuoteStyle.Csv), {"Lv0", "Lv1", "Lv2", "Lv3"}),
    #"Removed Columns" = Table.RemoveColumns(#"Split Column by Delimiter",{"Staff Name", "Supervisor", "Lv0"}),
    #"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([Lv3] <> null))
in
    #"Filtered Rows"

Screenshot 2020-12-03 234733.pngScreenshot 2020-12-03 234759.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors