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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
armandprr92
Frequent Visitor

Multiple parents hierarchy - Find longest path

Hello, I have a multiple parents hierarchy and I would like to find the most time consuming path available.

armandprr92_3-1742152778714.png

armandprr92_4-1742153040844.png

 

In blue the original table and in orange the expected result.

 

I have found this function for finding the optimal path, but I've been unable to edit it to my needs. Dijkstra's Algorithm in Power Query

 

I'm quite lost right now.

 

Thank you very much for your help.

 

1 ACCEPTED SOLUTION

Here's the PBIX with both shortest and longest path

 

lbendlin_1-1742159041200.png

 

View solution in original post

5 REPLIES 5
v-mdharahman
Community Support
Community Support

Hi @armandprr92,

Thanks for reaching out to the Microsoft fabric community forum.

 

It looks like you want to find the highest time consuming path in your data hierarchy. As @lbendlin already provided a response to your query, please go through it and accept it as solution if it solves yours problem.

 

I would also take a moment to thank @lbendlin, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.

 

If I misunderstand your needs or you still have problems on it, please feel free to let us know.  

Best Regards,
Hammad.
Community Support Team

 

If this post helps then please mark it as a solution, so that other members find it more quickly.

Thank you.

lbendlin
Super User
Super User

Here's a more contemporary implementation in SQL.  Should be possible to convert that into Power Query.

 

Dijkstra's Algorithm – SQLServerCentral

Here is the PBIX file with your data and the algorithm you mentioned. The algorithm calculates the shortest path, not the longest path.

 

lbendlin_0-1742157072838.png

 

Here's the PBIX with both shortest and longest path

 

lbendlin_1-1742159041200.png

 

Super thanks! I've done multiple checks and it works as expected.

Thank you very much for the effort.

 

PS: To give some context, I needed it in order to calculate a gantt with multiple parent hierarchy. In that gantt I have a start time of the first installation but not for the others. Then for the other's start time I needed to calculate the most far away date, that is exacly where it will start that installation. And so on.

 

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.