Forum Discussion
Problem using the PATH function
- 7 years ago
You can also directly add a PATH using "M"/Power Query.
Please see the attached file's Query Editor as well
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRR0lEyNDRSitWJVjIGsU3ATENDINsYwjRGMM2MEGxDc5ByM4hWIyNDJJ4FnBMLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [EmployeeKey = _t, ParentEmployeeKey = _t]), ChangedType = Table.TransformColumnTypes(Source,{{"EmployeeKey", type text}, {"ParentEmployeeKey", type text}}), NewStep=Table.AddColumn(ChangedType, "Path", each let myfunction=(myvalue)=> let mylist=Table.SelectRows(ChangedType,each [EmployeeKey]=myvalue)[ParentEmployeeKey], result=Text.Combine(mylist) in if result= null or result ="" then "" else if @myfunction(result)=null or @myfunction(result)="" then result else result & "|" & @ myfunction(result) in Text.Combine(List.Reverse(List.RemoveItems({[EmployeeKey]}&{[ParentEmployeeKey]}&Text.Split(myfunction([ParentEmployeeKey]),"|"),{"",null})),"|")) in NewStep - 7 years ago
Hi Zubair_Muhammad ,
This is perfect, but it seems to have one flaw. If the table is too big I get this error
Expression.Error: Evaluation resulted in a stack overflow and cannot continue.
When I limit the table it works fine, but if you know what causes the error I would like to know :-)
BR
Esben
Hi eacy,
Please refer to Zubair_Muhammad' suggestion which works in your scenario.
As using DAX funtion PATH would prompts such an error.
It doesn't apply to your scenario, because "Values inparent_columnNamemust be present inID_columnName. That is, you cannot look up a parent if there is no value at the child level.", as mentioned in document.
Best regards,
Yuliana Gu