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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mathewsnjoy
Frequent Visitor

How to add parameter to R Script for visualization ?

Hi All,

         I have an R Script which basically contains a function which requires a string as a parameter.Something like new.function("RED").   { if ("RED" then plot(a) else plot(b)}. R script works fine in R Studio. But I cannot pass this string using Power BI.

Does Power BI support this argument passing? In another forum page found that in data importing we can use R.Execute (& TextFrom(Parameter1.))

But this is not working in R Script for Visualization. Can anyone help?

 

Regards

 

Matt

2 REPLIES 2
campagnol54
Advocate I
Advocate I

I provide a solution in Power BI assistant (look at "R parameters" tab)

 

This project is meant to help Power BI desktop developpers providing functions which are not included natively or giving useful information and links. Download .pbix files. Documentation is included in the reports.

####### IMPORTANT : in Power Query, type your Windows user name in the parameter 'WindowsUserName'

Github :   https://github.com/didierterrien/Power-BI-assistant

LinkedIn :   https://www.linkedin.com/in/didier-terrien-657535b7/

Very good tutorial of some functions by Ruth Pozuelo (Curbal) :   https://www.youtube.com/watch?v=Jg7n_cLjtTw

 

v-sihou-msft
Microsoft Employee
Microsoft Employee

@mathewsnjoy

 

No, it's not supported to pass argument into R script you executed in R visual. Then parameter you mentioned is query parameter which is only for retrieving data only, you can call it in Power Query (Advanced Editor). However, it doesn't work for R visual scenario. When execute R script in R visual, you can only pass data field to generate data frame.

 

Regards,

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.