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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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
Users online (217)