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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
Anonymous
Not applicable

Published Power BI R Visual Missing Category Names

I've created a few visuals using R in Power BI. I can't get the names of the different projects to show up when I publish the visual though. It just replaces the names with 1, 2, 3, and 4. I've included a screen shot of what the visual looks like in Power BI desktop and when I publish it on the service. I've also included my code below. Is there a way I can fix this?Desktop VisualDesktop VisualService VisualService Visual

# 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(Project, Spend, MAmountPostive)

# dataset <- unique(dataset)

 

# Paste or type your script code here:

library(ggplot2)

library(gridExtra)

library(scales)

 

color1 = "#75CDE5"

color2 = "#223974"

s = 3500000

 

All1 <- sum(dataset$Spend)

All2 <- sum(dataset$MAmountPostive)

 

categorical = append("All",dataset$Project)

actual = append(All2,dataset$MAmountPostive)

target = append(All1,dataset$Spend)

 

data <- data.frame(categorical, actual, target)

ggplot(data, aes(categorical, target)) +

geom_col(fill = color1, width = 0.7) +

geom_col(aes(categorical, actual), fill = color2, width = 0.5) +

labs(title = "Project Spend", x = "", y = "") +

geom_text(aes(label = paste0("$",format(round(actual/1e6, 1)),"M"),

y = ifelse(actual < 2*s, ifelse(actual < target, actual + s, actual + 2.5*s), ifelse(actual < target, actual - s, actual + s))),

color = ifelse(actual < 2*s, ifelse(actual < target, "black", "black"), ifelse(actual < target, "white", "black")), fontface = "bold", size = 5) +

geom_text(aes(label = paste0("$",format(round(target/1e6, 1)),"M"),

y = ifelse(actual < 2*s, ifelse(target - actual < s, ifelse(actual < target, target + 2.5*s, target),ifelse(actual < target, target + s, target + s)), ifelse(actual < target, target+ s, target - s))),

color = ifelse(actual < 2*s, ifelse(target - actual < s, ifelse(actual < target, "black", "white"),ifelse(actual < target, "black", "black")), ifelse(actual < target, "black", "white")), fontface = "bold", size = 5) +

theme(panel.grid.major.y = element_blank(),

panel.grid.minor.y = element_blank(),

panel.grid.major.x = element_line("grey"),

panel.grid.minor.x = element_blank(),

panel.background = element_blank(),

plot.title = element_text(hjust = 0.5, size = 20),

axis.text = element_text(size = 15, face = "bold", color = "black"),

axis.text.y = element_text(hjust = 1),

axis.ticks.y = element_blank(),

plot.margin = margin(t = 10, r = 35, b = 0, l = 0)) +

scale_y_continuous(labels = dollar) +

coord_flip()

0 REPLIES 0

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.

Top Solution Authors