Forum Discussion
Asina
3 years agoHelper III
Finding paths connected through a node. Data filtering
I have a table which resembles the below. The columns explained: Main contains the name and the pathway number. The Main can therefore contain nodes called Str1 or Str2, which indicates where it...
- 3 years ago
Try
Connected Mains = VAR InitialNodes = UNION( VALUES( 'Table'[Str1] ), VALUES( 'Table'[Str2] ) ) VAR ConnectedMains = CALCULATETABLE( VALUES( 'Table'[Main] ), 'Table'[Str1] IN InitialNodes || 'Table'[Str2] IN InitialNodes, REMOVEFILTERS( 'Table' ) ) VAR ConnectedMainsExlcudingCurrent = EXCEPT( ConnectedMains, { SELECTEDVALUE( 'Table'[Main] ) } ) VAR Result = CONCATENATEX( ConnectedMainsExlcudingCurrent, 'Table'[Main], ", " ) RETURN Result - 3 years ago
If I understand correctly you want a list of mains and all the nodes they are connected to. You could do another table like
Main All Connected = GENERATE ( ALLNOBLANKROW ( 'Main Neighbours'[Radialnr-rettet] ), DISTINCT ( UNION ( CALCULATETABLE ( VALUES ( 'Main Neighbours'[Connected To] ) ), CALCULATETABLE ( VALUES ( 'Main Neighbours'[Neighbours Neighbour] ) ) ) ) )
johnt75
3 years agoSuper User
Try
Connected Mains =
VAR InitialNodes =
UNION( VALUES( 'Table'[Str1] ), VALUES( 'Table'[Str2] ) )
VAR ConnectedMains =
CALCULATETABLE(
VALUES( 'Table'[Main] ),
'Table'[Str1] IN InitialNodes
|| 'Table'[Str2] IN InitialNodes,
REMOVEFILTERS( 'Table' )
)
VAR ConnectedMainsExlcudingCurrent =
EXCEPT( ConnectedMains, { SELECTEDVALUE( 'Table'[Main] ) } )
VAR Result =
CONCATENATEX(
ConnectedMainsExlcudingCurrent,
'Table'[Main],
", "
)
RETURN
ResultAsina
3 years agoHelper III
Hi johnt75
Thank you for replying.
You are on the right track, however not quite there yet.
Using the above mentioned code gives me the entire list of Main, not the ones that the selected Main is connected to.
So to check what I mean..you can increase the row of the table above by 3 and call the new Main Ras20 then make a new path that has no values in Str1 and Str2 that is the same as the rows above.
You will see that the code gives you still the Main that is not even connected to it.
- johnt753 years agoSuper User
I can't replicate the problem.