NETWORK.LAYOUT OpenBI
Coordinates to draw the network's nodes, heavier edges closer.
Group: Networks. OpenBI’s own: DAX has no function of this name.
Syntax
NETWORK.LAYOUT ( <links>, <from>, <to> [, <weight>] [, <directed>] )
| Parameter | Type | Description |
|---|---|---|
links | Table | The rows that make the network, one link a row: a table of the model or a table expression, as the filters leave it. |
from | Expression evaluated for each row | One end of each row's link, such as a payer, a customer or a place. |
to | Expression evaluated for each row | The other end of each row's link. |
weight | Expression optional, evaluated for each row | How heavy each row's link is, such as an amount or a count; never negative. Left out, or given as the constant BLANK (), every row weighs 1. |
directed | Boolean optional | TRUE when each link runs one way, from its first end to its second. FALSE or left out, a link works both ways. |
Returns
Table. A row a node, with the columns Node, X and Y.
Remarks
- The positions come from a force-directed layout (Fruchterman and Reingold): linked nodes pull together, all nodes push apart.
- A heavier link pulls its ends closer, but at most twice as hard as a very light one, so one very large amount does not squeeze the picture into a point.
- X and Y have no unit: only how far nodes are from each other matters.
- The same rows always give the same positions, in whatever order they come. 0.3.77 numbers the nodes by their values, so they can sit elsewhere than 0.3.76 put them, in a drawing of the same kind.
- Rows where an end is blank, or where both ends are the same node, add no link; the end that is there still counts as a node.
Compared with DAX
An OpenBI function: DAX has none like it, so a measure or query that uses it works in OpenBI only, not in Power BI or Analysis Services.
Examples
Where to draw seven friends
Rounded to two decimals. The two triangles end up on either side, Gus at the far end.
EVALUATE
VAR Links =
DATATABLE (
"From", STRING, "To", STRING,
{
{ "Ann", "Bo" }, { "Ann", "Cy" }, { "Bo", "Cy" }, { "Cy", "Di" },
{ "Di", "Ed" }, { "Ed", "Fay" }, { "Di", "Fay" }, { "Fay", "Gus" }
}
)
RETURN
SELECTCOLUMNS (
NETWORK.LAYOUT ( Links, [From], [To] ),
"Node", [Node],
"X", ROUND ( [X], 2 ),
"Y", ROUND ( [Y], 2 )
)
| Node | X | Y |
|---|---|---|
| Ann | -2.13 | 0.52 |
| Bo | -2.2 | -0.2 |
| Cy | -1.18 | 0.06 |
| Di | 0.26 | -0.08 |
| Ed | 1.05 | -0.62 |
| Fay | 1.55 | 0.03 |
| Gus | 2.65 | 0.28 |
Related functions
NETWORK.EDGES, NETWORK.NODES, NETWORK.EMBED.
Open Graph, OpenBI's graph library, does the work: layout_fruchterman_reingold. See the OAX network functions and Open Graph.