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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
indu
Helper II
Helper II

power bi Table Visuilation in R

Hi,

 

I want to display Conditional color Formatting in table with more than 3  colors and disable sorting icon in Table Chart.

So We donot have solution in current power bi.That is the reason I Planning to go R script with Power bi.

So Could you please provide me any Code in R with desktop.

7 REPLIES 7
TomMartens
Super User
Super User

Hey,

 

maybe my answer to this question

https://community.powerbi.com/t5/Desktop/Can-this-be-done-in-Power-BI-Don-t-need-solution-just-to-kn...

provides input for an alternative approach to your requirement, by using the UNICHAR() function.

 

Regards



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
v-sihou-msft
Microsoft Employee
Microsoft Employee

HI,

 

Thank you for giving reply.

 

I am trying to Create Conditional color in grid using below code.but I am getting small error.that is "could not find function "%>%"" Please help me out .how to resolve it.

library(DT)
options(DT.options = list(pageLength = 5))
df = as.data.frame(cbind(matrix(round(rnorm(50), 3), 10), sample(0:1, 10, TRUE)))
# style V6 based on values of V6
datatable(df) %>% formatStyle(
'V6',
backgroundColor = styleEqual(c(0, 1), c('gray', 'yellow'))
)

HI,

I have tried in R Language.It is working fine.But I need in Power bi Desktop with R.

 

I have tried with same code in Power bi Desktop.

It is Coming error like "error: could not find function "%>%" pipe"

 

PLease help me out.

Hey,

 

I guess you have to load the  R package that enables the usage of piping.

 

I use the package magrittr.

 

I guess your are using R studio as dev ide, within R studio some packages do not have to be explicitly loaded.

 

Add the line 
library("magrittr") to your R script that you are using in Power BI and I assume it will work.

 

Regards



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Yes Right I am Using Rstudio only.

I have added below line.But Still I am getting error.

library("magrittr")

COuld you please help me the correct code in Power Bi with R.

 

PLease find below code which I have Use In Power bi.

 

options(DT.options = list(pageLength = 5))
df = as.data.frame(cbind(matrix(round(rnorm(50), 3), 10), sample(0:1, 10, TRUE)))
library("magrittr")
# style V6 based on values of V6
datatable(df) %>% formatStyle(
'V6',
backgroundColor = styleEqual(c(0, 1), c('gray', 'yellow'))
)

Hey,

 

there is bad news,

  • the minor thing, you also have to reference the library DT using library("DT")
  • the major thing, the function datatable returns an HTML widget, currently the R script visual inside Power BI just supports objects of typ plots, this means that you currently can't achieve what you are looking for using the DT approach, unless you are willing to create a Custom R visual (no it's some same as the R script visual, you can start here: https://github.com/Microsoft/PowerBI-visuals/tree/master/RVisualTutorial)

Maybe you have to rethink, and give the function tableGrob from the gridExtra a try. Additional information is available here:

https://cran.r-project.org/web/packages/gridExtra/vignettes/tableGrob.html

 

This is what I'm using 🙂

 

Regards

 

Regards



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.