Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
eacy
Helper II
Helper II

Problem using the PATH function

Hi

 

I would like to use the DAX path function on my dataset but currently, it doesn't comply with the rules of the path function.

 

My dataset is missing a row with an empty parent column for the top parent like it should according to the documentation (I am missing the row marked with red.

 

EmployeeKey ParentEmployeeKey

121 
14112
314
113
133
1623
117162
221162
81162

 

Can anybody explain to me how I can add this row in either DAX or Power Query?

 

BR

Esben

2 ACCEPTED SOLUTIONS

@eacy 

 

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

PATH function.png


Regards
Zubair

Please try my custom visuals

View solution in original post

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

View solution in original post

12 REPLIES 12

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.