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
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
Employee
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
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.