Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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.
Hey,
maybe my answer to this question
provides input for an alternative approach to your requirement, by using the UNICHAR() function.
Regards
This depends your dataset and your logic for conditional formatting. See these similar threads below:
https://stackoverflow.com/questions/18663159/conditional-coloring-of-cells-in-table
https://stackoverflow.com/questions/31323885/how-to-color-specific-cells-in-a-data-frame-table-in-r
Also refer to code in following articles:
Conditional Formatting of a Table in R
More Examples on Styling Cells, Rows, and Tables
Regards,
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
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,
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