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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dynamic Coloring with R Scripting

Hello!  

 

I have a side-passion project I'm working on.  Including a very basic DUMMY data set below.  What I am trying to create is a box and whisker plot through R, for each individual ID.  I can actually do this part, but what I also need is for the individual points to appear by company, and for a single company to be a different color, depending on user choice.  

 

For example, if the first sheet of the dashboard had a slicer where the end user chose their company (with this data, lets say they chose Z, from their choices of X, Y and Z).  When they go to the next tab, when looking at the box/whisker plot for ID a, they would see 3 points with the graph (X,Y,Z), and the point for Z would be colored RED and the others would be GREY (or something to this effect).  

 

I can create the R-boxplot visuals, but cannot get the dynamic color changing.  Any suggestions?  I'm not sure if I need measures, or columns, or what might be best. Thank you all for your help in advance.  

 

Company ID PRICE
Z a 100
Z b 99
Z c 98
Z d 98
Y a 99
Y b 99
X a 100
X c 101
X d 98

2 REPLIES 2
Icey
Community Support
Community Support

Hi @Anonymous ,

 
Is this problem sloved?
 
If it is sloved, could you kindly accept it as a solution to close this case?  
 
If not, please let me know.  
 
Best Regards
Icey
Icey
Community Support
Community Support

Hi @Anonymous ,

I am currently unable to fulfill your request. Maybe you can try this.

The code in R Script Editor is below:

data<-dataset
library(ggplot2)
ggplot(data,aes(ID,PRICE))+geom_boxplot()+geom_boxplot(aes(colour = ID))+facet_grid(~Company)

Dynamic Coloring with R Scripting5.PNGDynamic Coloring with R Scripting6.PNG

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.