Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

R script visual: "Can't display this visual"

Hi!

I am using the following R script (see code in blue) to generate a Sankey diagram visual . It works perfectly in R Studio but it does not generate something in Power BI and it says "Can't display this visual". Does anyone knwo what the issue could be?

 

annanilsson_0-1645794513501.png

 

 

library(tidyr)
library(dplyr)
library(networkD3)
# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
dataset <- data.frame(group, ID, name, source, target, value)
dataset <- unique(dataset)

# Paste or type your script code here:
nodes <- data.frame(name = dataset$name, ID = dataset$ID) %>% drop_na(ID)
links <- data.frame(group = dataset$group,source = dataset$source,target=dataset$target,value=dataset$value)

nodes$group <- "unicol"
 
my_color2 <- 'd3.scaleOrdinal() .domain(["a", "unicol"]) .range(["#008387", "#A9AEAB"])'

sankeyNetwork(Links = links, Nodes = nodes, Source = "source",
Target = "target", Value = "value", NodeID = "name",
units = "Ton", fontSize = 20, nodeWidth = 20,
fontFamily = "sans-serif", NodeGroup = "group", LinkGroup = "group",
colourScale = my_color2)
4 REPLIES 4
v-luwang-msft
Community Support
Community Support

HI @Anonymous ,

You may have a look at below articles to check if those are helpful or not.

 

https://community.powerbi.com/t5/Desktop/R-graphics-libraries-does-not-work-in-PBI/td-p/259473

https://medium.com/@dr_eldersveld/r-visuals-in-power-bi-beyond-plots-74c618f2e6f3

https://docs.microsoft.com/en-us/power-bi/desktop-r-visuals

 

 

Did I answer your question? Mark my post as a solution!


Best Regards

Lucien

Anonymous
Not applicable

I am sorry, but this link did not help me to solve this.

It shows a technique for when the R is not returning a png/image that can be rendered. You can raster what you see in R Studio to an image so that it shows up.

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Microsoft Employee
Microsoft Employee

Please see this article.

Hijacking the R Visual - P3 Adaptive

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors