Forum Discussion
Finding paths connected through a node. Data filtering
- 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] ) ) ) ) )
Can you post the exact code you are using? I think you may be missing a close bracket or something
- johnt753 years agoSuper User
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] ) ) ) ) ) - johnt753 years agoSuper User
You have an extra ]
Main Neighbours = GENERATE ( ALLNOBLANKROW ( dbo_Cables_10kV[Radialnr-rettet] ), VAR InitialNodes = UNION ( CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Straekning.1] ) ), CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Straekning.2] ) ) ) VAR ConnectedMains = CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Radialnr-rettet] ), dbo_Cables_10kV[Straekning.1] IN InitialNodes || dbo_Cables_10kV[Straekning.2] IN InitialNodes, REMOVEFILTERS ( dbo_Cables_10kV ) ) VAR ConnectedMainsExlcudingCurrent = EXCEPT ( ConnectedMains, { dbo_Cables_10kV[Radialnr-rettet] } ) RETURN ConnectedMainsExlcudingCurrent ) - Asina3 years agoHelper III
Ah I see thank you. But you dont get the error: Funktionen GENERATE does not allow two columns with the same name 'dbo_Cables_10kV'[Radialnr-rettet]?
- johnt753 years agoSuper User
Ah, OK.
Main Neighbours = GENERATE ( ALLNOBLANKROW ( dbo_Cables_10kV[Radialnr-rettet] ), VAR InitialNodes = UNION ( CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Straekning.1] ) ), CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Straekning.2] ) ) ) VAR ConnectedMains = CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Radialnr-rettet] ), dbo_Cables_10kV[Straekning.1] IN InitialNodes || dbo_Cables_10kV[Straekning.2] IN InitialNodes, REMOVEFILTERS ( dbo_Cables_10kV ) ) VAR ConnectedMainsExlcudingCurrent = EXCEPT ( ConnectedMains, { dbo_Cables_10kV[Radialnr-rettet] } ) RETURN SELECTCOLUMNS ( ConnectedMainsExlcudingCurrent, "Connected to", dbo_Cables_10kV[Radialnr-rettet] ) ) - Asina3 years agoHelper III
Hi johnt75
a quick question.
If I wanted to see the Neighbors Neighbor in a new column, in the new table we created. How do I add it in the base code of the new table? Since as far as I know, the size of the table is tangible when its in forming process i.e. creation of a new table.
Also If I want another column in the same table showing all the filtered values: ( Main -> Neighbor of Main -> Neighbors Neighbor ) that would be perfect...
This way I can just connect this column to the picture table and have it all solved in 1 go.
is it possible?
I hope I am not bothering you too much..But you have been through this with me, and know how it works 🙂 thanks
example:
- johnt753 years agoSuper User
I'm not sure what you mean by the second column, but in principle you could get the neighbours neighbour column by nesting GENERATE statements. Not sure if the below will work but you can try
Main Neighbours = GENERATE ( GENERATE ( ALLNOBLANKROW ( dbo_Cables_10kV[Radialnr-rettet] ), VAR InitialNodes = UNION ( CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Straekning.1] ) ), CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Straekning.2] ) ) ) VAR ConnectedMains = CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Radialnr-rettet] ), dbo_Cables_10kV[Straekning.1] IN InitialNodes || dbo_Cables_10kV[Straekning.2] IN InitialNodes, REMOVEFILTERS ( dbo_Cables_10kV ) ) VAR ConnectedMainsExlcudingCurrent = EXCEPT ( ConnectedMains, { dbo_Cables_10kV[Radialnr-rettet] } ) RETURN SELECTCOLUMNS ( ConnectedMainsExlcudingCurrent, "Connected to", dbo_Cables_10kV[Radialnr-rettet] ) ), CALCULATETABLE ( VAR InitialNodes = UNION ( CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Straekning.1] ) ), CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Straekning.2] ) ) ) VAR ConnectedMains = CALCULATETABLE ( VALUES ( dbo_Cables_10kV[Radialnr-rettet] ), dbo_Cables_10kV[Straekning.1] IN InitialNodes || dbo_Cables_10kV[Straekning.2] IN InitialNodes, REMOVEFILTERS ( dbo_Cables_10kV ) ) VAR ConnectedMainsExlcudingCurrent = EXCEPT ( ConnectedMains, { dbo_Cables_10kV[Radialnr-rettet], SELECTEDVALUE ( [Radialnr-rettet] ) } ) RETURN SELECTCOLUMNS ( ConnectedMainsExlcudingCurrent, "Neighbours neighbour", dbo_Cables_10kV[Radialnr-rettet] ), TREATAS ( { [Connected to] }, dbo_Cables_10kV[Radialnr-rettet] ) ) ) - Asina3 years agoHelper III
Thank you, it does work for the Neighbors Neighbor column 👍.
What I meant with a second column, was that a column that sums the total of filtered.
In this: Main + Neighbor of Main + Neighbors Neighbor. This makes the table large. But, I can use this new column to connect to the picture table and then have the problem solved. is it possible ?
- Asina2 years agoHelper III
Hi johnt75
I wonder if you remember the above solution you provided.
I have an issue where Connected To column produces a blank which causes it to make the Neighbours neighbour to be wrong, as it uses the blank in connected to in Treatas(), which ends up giving wrong neighbours which is additional to the ones that are right.
And i can only filter with All to All in the Model. Any solution to the code which says ignore blanks in connected to or remove it all together?
Thanks again