Forum Discussion
pedroccamaraDBI
5 years agoPost Partisan
Create Parent Hierarchy
Hey guys I believe this is a tuff one. How can i creat a parent column out of 1 column like this? Thanks to all Pedro
- 5 years ago
Hello pedroccamaraDBI
try this
let Source = Excel.Workbook(File.Contents("C:\Users\Pedro\Desktop\Accounts.xlsx"), null, true), Table1_Table = Source{[Item="Table1",Kind="Table"]}[Data], #"Changed Type" = Table.TransformColumnTypes(Table1_Table,{{"GL SNC AccountID", type text}, {"GroupingCategory", type text}}), BufferMaterial = List.Buffer(#"Changed Type"[GL SNC AccountID]), AddParent = Table.AddColumn ( #"Changed Type", "Parent", (row)=> List.Last(List.Select(List.Transform(BufferMaterial, (trans)=> if trans = Text.Start(row[GL SNC AccountID], Text.Length(trans)) and trans<> row[GL SNC AccountID] then trans else null),each _<> null)) ) in AddParentCopy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
pedroccamaraDBI
5 years agoPost Partisan
Hello ziying35
Thank you very much for your answer but for some reason it shows an error:
"Expression.Error: The name 'Text.StartWith' wasn't recognized. Mke sure it's spelled correctly."
But as you may see it is....
ziying35
5 years agoImpactful Individual