The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I'm currently using field parameters to create dynamics PowerBI graphs. Works GREAT!
And I'm using R Visual Objects to show ggplot2 graphs with PowerBI data. It works GREAT too!! I just need to add the field to the visual objetc as with any other. I.E: I add the fields 'age' and 'hour' from my PowerBI data, and refer them in my ggplot:
Hi @Francisco_G_Cal ,
Did you get any error message? Could you please share the related R script with us for the further investigation? By the way, is there any space or special character in your field parameter name? It need to be enclosed in backticks in R if the column names include spaces or special characters. The following one is the thread which has the similar problem as yours, hope it can help you resolve the problem.
r - Unable to plot ggplot graph on Power BI - Stack Overflow
library(dplyr)
df <- tibble(
incident_date = dataset$`Incident Date`,
incident_regular = dataset$`# Incident - Regular`
)
Regressor = lm(formula = incident_regular ~ incident_date, data = df)
ggplot(df) +
geom_point(aes(x = incident_date, y = incident_regular), color ='red') +
geom_line(aes(x = incident_date, y = predict(Regressor, new data = df)), color ='blue') +
ggtitle('Incident Count Prediction') +
xlab('Incident Date') +
ylab('Number of Incident')
Best Regards
I have no problem for drawing my ggplot in R.
Theese are the vars I add to the R Script Object
The last one, 'Numericas', is a FIELD PARAMETER
This is my code (the commented lines are created by PowerBI)
# El código siguiente, que crea un dataframe y quita las filas duplicadas, siempre se ejecuta y actúa como un preámbulo del script:
# dataset <- data.frame(Accesos, Edad, Hora)
# dataset <- unique(dataset)
# Pegue o escriba aquí el código de script:
library(ggplot2)
color_palette <- colorRampPalette(c("steelblue", "darkblue"))(length(dataset$Accesos))
# Crear el scatterplot con ggplot2
ggplot(dataset, aes(x = Edad, y = Hora, size = Accesos, alpha = Accesos, color = Accesos)) +
geom_point(stroke = NA) +
scale_size_continuous(range = c(2, 10)) +
scale_alpha_continuous(range = c(0.1, 0.8)) +
scale_color_gradientn(colors = color_palette) + # Aplicar la paleta de colores
labs(x = "Edad", y = "Hora", title = colnames(dataset))
And it works perfectly:
But, if instead a field value, I use the Field Parameter
User | Count |
---|---|
80 | |
78 | |
37 | |
34 | |
31 |
User | Count |
---|---|
93 | |
81 | |
60 | |
49 | |
49 |