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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.