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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
JoeFields
Frequent Visitor

New Column to concatenate text for nested tree hierarchies

I have a table of data that is a list of nested tree nodes and I am looking for a way to concatenate a specific column with the "name" data to display the full path to each node excluding the root. Here is a simplified example:

 

parent_ididnamefull path
 0001Root 
00010002Level 1Level 1
00020003Area ALevel 1 -> Area A
00020004Area BLevel 1 -> Area B

 

I have the columns above except the "full path" which I need to write a DAX expression to create. I need a new colum formula that can loop through each line and lookup the parent_id in the id column and return the name to prepend it to the original node name then continue until it hits a parent_id that is blank indicating it is at the root. I don't need the root name in the full path.

 

Thanks!

5 REPLIES 5
wdx223_Daniel
Super User
Super User

wdx223_Daniel_0-1613281206487.png

 

amitchandak
Super User
Super User

@JoeFields , Have you alreay tried path in power bi  and it did not helped you ?

https://radacad.com/parsing-organizational-hierarchy-or-chart-of-accounts-in-power-bi-with-parent-ch...

 

https://www.thebiccountant.com/2019/10/03/parent-child-hierarchies-with-multiple-parents-in-power-bi...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I have not tried Path but it might get me a little bit closer. My issue is that I need Path but with more of a key-value pair lookup where the id and the parent-id is used to find each parent-child relationship but then have it use the name column to create the path. Path appears to only work for the unique id. I might be able to get there if I can build the path then parse each id in the path to create the path using the name columns. Basically use an intermediate column with the path (based on ids) then iterate through each piece of the path to make the path (based on names). How can I loop through the path and do a lookup to replace the id with the name?

 

Also, I am trying to get the Path to work but getting this error. It appears to not like if parent_id column contains blanks but a blank means it is at the root. Documentation indicates Path should be able to handle blanks and I would assume this is how it knows it has hit the root.

 

Snag_2d6de79d.png

 

Here is a snapshot of my actual data to show the structure I have. Each id is a GUID and the depth of the branches can vary but most likely no more than 10 levels deep at the most extreme.

 

JoeFields_0-1613158473888.png

 

orphan records.

you have dirty data. (omg, now i know why i couldnt get it to work)

maybe change orphan record parent key to blank (or delete) before letting Dax get hold of it.

 

rfigtree_0-1613285110916.png

rfigtree_1-1613285165284.png

 

 

yeah dax path needs a certain structure of data to work.

 

Try using power query, with self joins.

I exploded a BOM structure down to 7 levels using power query and it worked well.

Can get a little slow if you have a big data structure but does the job.

 

(just remebered utilizing Table.Buffer() in PQ. Speeds it up a bit, or maybe i was just imagining it, who knows?)

 

Guess you could MS ACCESS or other DB if Power Query not up to the job.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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