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
ah12
Frequent Visitor

Need help with really tough iterative function (maybe List.Generate ?)

Hi

 

I'm struggling with a problem I have tried to solve myself but I am now running out of time, so I turn to this community brain !

 

SET-UP

 

I have a list of points on a network, some of which intersect with each other.  These interactions can be shown in two columns as follows:

 

ABCD | EFGH

AABB | HGYT

TTYF | UYWR

HGYT | PQLU

WOWI | PLAS

SSEW | PQLU

 

... and so on.

 

There are hundreds of these pairings and there are two important things to consider.

 

Firstly, points connect with each other and as an example (above), we can see that point AABB connects to HGYT and then (further down the list) we can see that point HGYT connects to point PQLU.

 

Secondly, each point may or may not "terminate".  So, the above points would have the following status:

 

ABCD | T

EFGH |

AABB |

HGYT| 

TTYF | 

UYWR | T

PQLU | 

SSEW | T

WOWI | T

PLAS |

 

 

If they "terminate", they have a "T" in the column next to them and if they do not terminate they have a blank (currently this status is in a separate list, and instead of blank it could be anything).  Actually, for my current attempts to solve the problem I have used 1 for "terminate" and 0 for "not terminate".

 

PROBLEM

 

I need to look at each point in a list and track its connections until it "terminates".  So, for a very simple example, taking point AABB, we can see that it connects to HGYT, then refer to our status list and can see that HGYT does NOT terminate, so we continue to consider where HGYT connects to, and see that PQLU does NOT terminate.  PQLU also connects to SSEW, which does terminate.  In this simple case, we have the "paths" for AABB: which is AABB | HGYT and HGYT | PQLU.  

 

RULES

 

We don't need to consider whether the starting point has a "T" flag ("T" for terminate) or not, since we always want to include the first path (in the case above, AABB | HGYT.

 

 

We need to keep going down all paths until we hit a "T">

 

There will sometimes be mutiples branches from the starting point AND along the way.  We don't get crazy numbers of permutations but we could branch 6 times in one direction and 3 times down another path before hitting a "T".

 

My progress so far has been to lookup the termination status of each point in the pairs (using 1 for "T" and 0 for "non T"), like this:

 

ABCD | EFGH | 1 | 0

AABB | HGYT | 0 | 0

TTYF | UYWR | 0 | 1

 

... and so on.

 

I can then take the current point I am interested in (AABB), define that as a variable, and then use that to filter each column of points so I only get the other points where AABB is listed.

 

My problem, is then moving on to any subsequent connections (so, going down the HGYT branch, etc).

 

I thought about using a looping function or trying to work with List.Generate but the truth is, I need some help at this stage.

 

I'd like to return a list of "pairs of points" for each starting point: so for the example above, for considering the point AABB I'd like to return:

 

AABB | AABB | HGYT

AABB | HGYT | PQLU

 

where the first column contains the point we are working with and the next two columns are the path (containing the two points in the first list I showed at the start).

 

Hopefully this is  an interesting enough problem that I will get multiple solutions.

 

As always, I appreciate the generosity and help of this community, and I look forward to learning from any responses put forward.

 

 

2 REPLIES 2
kcantor
Community Champion
Community Champion

@ah12

Unfortunately, I am time constrained on a project right now but I can offer the following link as help to complete your  project. Try this method:

https://www.daxpatterns.com/parent-child-hierarchies/

(I like to read through the forums while waiting on data to churn).





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ah12
Frequent Visitor

Hi kcantor, thanks for the recommendation. I wonder if the parent - child hierarchies approach would handle the fact that the relationship between the nodes are not so neat and are not "one-way" i.e. One node might lead to another and another two, which each split off. One of the two might then end there but the other might lead back to create a "circuit" to the earlier "path" .

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.

Top Solution Authors