Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I'm working with a parent-child hierarchy but in which some child values have different parents. For instance:
Child | Parent |
USA | Country |
France | Country |
Revenues | USA |
Revenues | France |
The hierarchy function PATH() does not support a hierarchy like that with same child for different parents. Is there any way to work with this kind of hierarchy?
Thanks!
Solved! Go to Solution.
@Anonymous
Try this custom Column from Query Editor
=let //Define your columns below c=[Child],p=[Parent],mytable=#"Changed Type",pc="Parent",cc="Child" in let mylist={c} & List.Generate(()=>[x=0,y=p,w=1],each [w] > 0,each [z=[y], x=Table.Column(Table.SelectRows(mytable,each Record.Field(_,cc)=z),pc),y=x{0},w=List.Count(x) ], each [y]) in Text.Combine(List.Reverse(List.RemoveItems( List.Transform(mylist,each Text.From(_)),{null,""})),"|")
country | USA | Revenues |
Country | France | Revenues |
recast your hierarchy, the parent "country" has 2 children, "USA" and "France", each of them has one child "Revenues"
Help when you know. Ask when you don't!
Yes, that's the hierarchy of the example. But now imagine that you have a table of thousands of rows instead of just 4. Then to build up the hierarchy you would use the PATH( <ID_ColumnName>, <Parent_ColumnName>) function, but this function
returns an error if parent_columnName value is different for those duplicates (which is the case).
Then my question was, how to build the hierarchy anyway? I'm afraid it's not possible...
@Anonymous
Try this custom Column from Query Editor
=let //Define your columns below c=[Child],p=[Parent],mytable=#"Changed Type",pc="Parent",cc="Child" in let mylist={c} & List.Generate(()=>[x=0,y=p,w=1],each [w] > 0,each [z=[y], x=Table.Column(Table.SelectRows(mytable,each Record.Field(_,cc)=z),pc),y=x{0},w=List.Count(x) ], each [y]) in Text.Combine(List.Reverse(List.RemoveItems( List.Transform(mylist,each Text.From(_)),{null,""})),"|")
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
22 | |
7 | |
6 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |