Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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.
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...
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,""})),"|")
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
27 | |
20 | |
15 | |
12 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
18 |