0

I tried by best to create sankey chart with R plotly package in powerBI, but failed. I can create sankey in RStudio with same code. I checked the official document that the package 'plotly' i used is supported by powerBI service. So there should be no reason the chart not displayed. https://learn.microsoft.com/en-us/power-bi/connect-data/service-r-packages-support

library("plotly")

a = read.csv('cleanSankey.csv', header=TRUE, sep=',')
node_names <- unique(c(as.character(a$source), as.character(a$target)))
node_names <- node_names[order(sub('.*_', '', node_names))]
nodes <- data.frame(name = node_names)
links <- data.frame(source = match(a$source, node_names) - 1,
target = match(a$target, node_names) - 1,
value = a$value)

node_x <- c(0, 0, 0, 0,
0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125,
0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25,
0.375, 0.375, 0.375, 0.375, 0.375, 0.375,
0.5, 0.5, 0.5, 0.5,
0.625, 0.6255, 0.625,
0.8, 0.8, 0.8,
0.999, 0.999)

node_y <- c(0.01, 0.02, 0.03, 0.04,
0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12,
0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08,
0.01, 0.02, 0.03, 0.04, 0.05, 0.06,
0.01, 0.02, 0.03, 0.04,
0.01, 0.02, 0.03,
0.01, 0.02, 0.03,
0.01, 0.02)

#Plot
plot_ly(type='sankey',
orientation = "h",
arrangement = "snap",
node = list (
label = node_names,
x = node_x,
y = node_y,
color = "grey",
pad = 15,
thinkness = 15,
line = list(color = "grey", width = 0.5)),

link = list(
source = links$source,
target = links$target,
value = links$value))

Then I I run above code in powerBI desktop, but powerBI says that 'Can't display the visual'.

enter image description here

Anyone has experience help to advice?

peace
  • 299
  • 2
  • 16
  • No, this is a HTML plot, that cannot work. You have to use **pbiviz**, see [here](https://towardsdatascience.com/interactive-power-bi-custom-visuals-with-r-a6a4ac998710). – Stéphane Laurent Feb 15 '22 at 10:13
  • Power BI uses version 4.9.2.2 currently, whereas CRAN for RStudio has version 4.10.0. Is this a new feature? – danlooo Feb 15 '22 at 10:24
  • i tried and it works with pbiviz. Sankey created by R plotly can be displayed in powerBI desktop and powerBI service – peace Feb 21 '22 at 06:17

0 Answers0