Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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 | |||
ParentID | ChildID | ParentID | ChildID | |
16 | 1 | 16 | 1 | |
16 | 2 | 16 | 2 | |
16 | 3 | 16 | 3 | |
16 | 4 | 16 | 4 | |
16 | 5 | 16 | 5 | |
17 | 6 | 17 | 6 | |
17 | 7 | 17 | 7 | |
17 | 8 | 17 | 8 | |
17 | 9 | 17 | 9 | |
17 | 10 | 17 | 10 | |
18 | 11 | 18 | 11 | |
18 | 12 | 18 | 12 | |
18 | 13 | 18 | 13 | |
18 | 14 | 18 | 14 | |
18 | 15 | 18 | 15 | |
null | 16 | |||
null | 17 | |||
null | 18 |
Solved! Go to Solution.
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!
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 is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
74 | |
58 | |
36 | |
31 |
User | Count |
---|---|
91 | |
59 | |
59 | |
49 | |
42 |