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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
MartinSlaa
Frequent Visitor

Script runtime error for published R script on the Power BI Service

Hello!

I have created a circular barchart in Power BI desktop using R. Everything works fine in Power BI Desktop. Image of the visual and 
the R-script can be seen below. However, when publishing the report I get the Script Runtime error and the visual won't display. 

MartinSlaa_0-1662013999170.png

 

R-script: 

library(tidyverse)

data <- dataset
data$AvgangstidGruppe <- factor(rep(data$AvgangstidGruppe))

 
# Set a number of 'empty bar' to add at the end of each group
empty_bar <- 4
to_add <- data.framematrix(NAempty_bar*nlevels(data$AvgangstidGruppe), ncol(data)) )
colnames(to_add) <- colnames(data)
to_add$AvgangstidGruppe <- rep(levels(data$AvgangstidGruppe), each=empty_bar)
data <- rbind(datato_add)
data <- data %>% arrange(AvgangstidGruppe)

#Setting AvgangstidGruppeNR to correct Id

data$AvgangstidGruppeNr[data$AvgangstidGruppe == "Formiddag"] <- 4
data$AvgangstidGruppeNr[data$AvgangstidGruppe == "Rush, ettermiddag"] <- 5
data$AvgangstidGruppeNr[data$AvgangstidGruppe == "Rush, morgen"] <- 3
data$AvgangstidGruppeNr[data$AvgangstidGruppe == "Sen kveld"] <- 7
data$AvgangstidGruppeNr[data$AvgangstidGruppe == "Tidlig kveld"] <- 6
data$AvgangstidGruppeNr[data$AvgangstidGruppe == "Tidlig morgen"] <- 2
data$AvgangstidGruppeNr[data$AvgangstidGruppe == "Natt"] <- 1

data <- data[order(data$AvgangstidGruppeNr), ]

data$id <- seq(1nrow(data))

# Get the name and the y position of each label
label_data <- data
number_of_bar <- nrow(label_data)
angle <- 90 - 360 * (label_data$id) /number_of_bar
label_data$hjust <- ifelseangle < -9010)
label_data$angle <- ifelse(angle < -90angle+180angle)

base_data <- data %>%
  group_by(AvgangstidGruppe) %>%
  summarize(start=min(id), end=max(id) - empty_bar) %>%
  rowwise() %>%
  mutate(title=mean(c(startend)))

base_data <- base_data[order(base_data$start), ]
 
grid_data <- base_data
grid_data$end <- grid_data$endcnrow(grid_data), 1:nrow(grid_data)-1)] + 1
grid_data$start <- grid_data$start -1
grid_data <- grid_data[-1,]

 
# Make the plot
ggplot(dataaes(x=as.factor(id), y=Påstigendefill=AvgangstidGruppe)) +       # Note that id is a factor. If x is numeric, there is some space between the first bar

geom_bar(aes(x=as.factor(id), y=Påstigendefill=AvgangstidGruppe), stat="identity"alpha=0.5) +
 
geom_segment(data=grid_dataaes(x = endy = 800xend = startyend = 800), colour = "grey"alpha=1size=0.3 , inherit.aes = FALSE ) +
geom_segment(data=grid_dataaes(x = endy = 700xend = startyend = 700), colour = "grey"alpha=1size=0.3 , inherit.aes = FALSE ) +
geom_segment(data=grid_dataaes(x = endy = 600xend = startyend = 600), colour = "grey"alpha=1size=0.3 , inherit.aes = FALSE ) +
geom_segment(data=grid_dataaes(x = endy = 500xend = startyend = 500), colour = "grey"alpha=1size=0.3 , inherit.aes = FALSE ) +
geom_segment(data=grid_dataaes(x = endy = 400xend = startyend = 400), colour = "grey"alpha=1size=0.3 , inherit.aes = FALSE ) +
geom_segment(data=grid_dataaes(x = endy = 300xend = startyend = 300), colour = "grey"alpha=1size=0.3 , inherit.aes = FALSE ) +
geom_segment(data=grid_dataaes(x = endy = 200xend = startyend = 200), colour = "grey"alpha=1size=0.3 , inherit.aes = FALSE ) +
geom_segment(data=grid_dataaes(x = endy = 100xend = startyend = 100), colour = "grey"alpha=1size=0.3 , inherit.aes = FALSE ) +
 
annotate("text"x = rep(max(data$id),8), y = c(100200300400500600700800), label = c("100""200""300""400""500""600""700""800") , color="grey"size=3 , angle=0fontface="bold"hjust=1) +

geom_bar(stat="identity"alpha=0.5) +
ylim(-500,1300) +
theme_minimal() +
theme(
    legend.position = "none",
    axis.text = element_blank(),
    axis.title = element_blank(),
    panel.grid = element_blank(),
    plot.margin = unit(rep(-1,4), "cm")
  ) +
coord_polar() +
geom_text(data=label_dataaes(x=idy=Påstigende+10label=Halvtimehjust=hjust), color="black"fontface="bold",alpha=0.6size=2.5anglelabel_data$angleinherit.aes = FALSE ) +
 
geom_segment(data=base_dataaes(x = starty = -20xend = endyend = -20), colour = "black"alpha=1size=2 )
geom_text(data=base_dataaes(x = titley = -20label=AvgangstidGruppe), hjust=c(0,0,0,0,0,0), vjustc(0,0,0,0,0,0), colour = "black"alpha=1size=0fontface="bold"inherit.aes = FALSE)

 

Script Runtime Error:

MartinSlaa_1-1662014000063.png

 


The error message is in Norwegian, but it says: "Try again later, or contact customer support".
Licence used: Pro Licence

R version used: 4.2.1
tidyverse version used: 1.3.2

What I found interesting is that when I created a simple barchart where I hard coded the values needed for the plot instead of using the data I have loaded into Power BI Desktop, the visual works after I publish it.
The loaded data I am trying to use is not exceeding the limit of 150 000 rows, as I have shaved it down to just 7 values and I still get the Script Runtime Error.

Any help in solving this would be much appreciated.
Thanks!

1 ACCEPTED SOLUTION
MartinSlaa
Frequent Visitor

Solved! 
Power BI was not able to display the graph when data column name contained æ, ø or å. 

View solution in original post

1 REPLY 1
MartinSlaa
Frequent Visitor

Solved! 
Power BI was not able to display the graph when data column name contained æ, ø or å. 

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.