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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
tjgagner
Frequent Visitor

Fixing Path Function | Appending Parent IDs to List of Child Parent Relationships

I am working on constructing an relationship in PowerBI that shows the relationships uses the path function documented here: https://www.daxpatterns.com/parent-child-hierarchies/ . One issue I am running into is that the query I have only has the parent/child table imported. This missing component there is that every parent needs to be seperately listed as a child. So what I believe I need to do is take a de-duped list from the ParentID columns and create new rows with the Parent listed as a child. I am looking for help doing this on the PowerQuery side in "M". 

 

Thanks for taking the time to read and potentially help solve.

 

From To
ParentIDChildID ParentIDChildID
161 161
162 162
163 163
164 164
165 165
176 176
177 177
178 178
179 179
1710 1710
1811 1811
1812 1812
1813 1813
1814 1814
1815 1815
   null16
   null17
   null18
1 ACCEPTED SOLUTION
vicky_
Super User
Super User

 

vicky__0-1734475228235.png

In power query, duplicate the orignial table, and re-work it so that you have the unique parent IDs as child IDs. Then you can append the second table back into the original table to get your desired result. My steps to transform the second table are listed below:

let
    Source = //your source here,
    #"Removed Columns" = Table.RemoveColumns(#Source,{"ChildID"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Columns"),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Duplicates",{{"ParentID", "ChildID"}}),
    Custom1 = Table.AddColumn(#"Renamed Columns", "ParentID", each null)
in
    Custom1

 Hope this helps!

View solution in original post

2 REPLIES 2
vicky_
Super User
Super User

 

vicky__0-1734475228235.png

In power query, duplicate the orignial table, and re-work it so that you have the unique parent IDs as child IDs. Then you can append the second table back into the original table to get your desired result. My steps to transform the second table are listed below:

let
    Source = //your source here,
    #"Removed Columns" = Table.RemoveColumns(#Source,{"ChildID"}),
    #"Removed Duplicates" = Table.Distinct(#"Removed Columns"),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Duplicates",{{"ParentID", "ChildID"}}),
    Custom1 = Table.AddColumn(#"Renamed Columns", "ParentID", each null)
in
    Custom1

 Hope this helps!

This worked for me, thanks @vicky_ !

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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