Reputation: 21
I'm trying to adapt the force directed graph by David Bacci (https://github.com/PBI-David/Deneb-Showcase/tree/main/Force%20Directed%20Graph) so I can filter the nodes by node name, but still see the connected target nodes.
The problem seems to be that the dataset filters out all of the target node and link information when the PowerBI slicer is applied. I've tried a few versions of the data starting with an appended table of my link and node fields in Power Query and then a Combined Table where the link and node info was joined to try and override the filter.
I eventually got the Combined table to carry the right field information through to the rest of my created tables, but then I found the filter being on seemed to interfere with the force transform causing the visual to not show anything, despite the log not showing any error messages.
I've run out of ideas for what to try next. Does anyone know if this can be done??
Thanks!!
Edited to add:
I've attached some screenshots below of my PowerBi report (with dummy data): Hopefully it's clear that even though the slicer is applied, nodes unrelated to 'Flamingo' are still showing. If I go into the relationship matrix and make 'name' from test_Nodes and test_Deneb tables related, then I get this: Although, I can see in your original version the relationship isn't there.
I've brought the nodes and links tables in in exactly the same way, created the appended table in the same way and they have the same structure. I also have't changed anything about the vega syntax in the deneb visual itself itself (apart from adding the new variables in).
Is there anything else I can try?
Upvotes: 2
Views: 224
Reputation: 30174
Something like this will work.
Change slicer to use Nodes[name]
Change measure to this:
Selection =
VAR val = SELECTEDVALUE(Nodes[name])
VAR source = CALCULATETABLE(VALUES(Links[source]), Links[target] = val)
VAR target = CALCULATETABLE(VALUES(Links[target]), Links[source] = val)
RETURN
SWITCH(TRUE(),
SELECTEDVALUE(Deneb[name]) == val, 1,
SELECTEDVALUE(Deneb[name]) IN source, 1,
SELECTEDVALUE(Deneb[name]) IN target, 1,
SELECTEDVALUE(Deneb[target]) == val, 1,
SELECTEDVALUE(Deneb[source]) == val, 1
)
Working:
Upvotes: 1