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.
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,""})),"|")
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 |
---|---|
10 | |
9 | |
9 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
11 | |
8 |