cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
indu Regular Visitor
Regular Visitor

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
Moderator v-sihou-msft
Moderator

Re: power bi Table Visuilation in R

Super User
Super User

Re: power bi Table Visuilation in R

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

Hamburg - Germany
If I answer you question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!
indu Regular Visitor
Regular Visitor

Re: power bi Table Visuilation in R

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'))
)

indu Regular Visitor
Regular Visitor

Re: power bi Table Visuilation in R

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.

Super User
Super User

Re: power bi Table Visuilation in R

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

Hamburg - Germany
If I answer you question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!
Highlighted
indu Regular Visitor
Regular Visitor

Re: power bi Table Visuilation in R

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'))
)

Super User
Super User

Re: power bi Table Visuilation in R

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

Hamburg - Germany
If I answer you question, please mark my post as solution, this will also help others.
Proud to be a Datanaut!