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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

published report using r source file for creating visuals

Hello,

 

I have a report created locally with R and PowerBI desktop.

In this report, I generate some plots by running R code from my computer. This means that in the "R script editor" I simply have a line like: "source("C:/Users/Myself/PowerBI/Script_Plot01.r")"

 

Now I want to publish this report. I have the 'pro' license, so it shouldn't be a problem...but I don't know 'where' to put the r code file to be available to PowerBI.

I have tried to link the source with a folder in Sharepoint, so having a line like: "source(" https:// myself. sharepoint.com /PowerBI /Script_Plot01.r  ")"

But it doesn't work. I got the following "Script Runtime Error":

Error in file(filename, "r", encoding = encoding) : cannot open the connection

In addition: Warning message: In file(filename, "r", encoding = encoding) : InternetOpenUrl failed: 'The server name or address could not be resolved'

 

I found a similar question back to 2018, but was not solved:

 https://community.powerbi.com/t5/Service/Published-R-reports-with-sourced-scripts/td-p/426422

 

Any help will be appreciated.

Thanks!

6 REPLIES 6
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

If you want to use R scripts to create visuals in Power BI, you need to do this.

Create Power BI visuals using R 

If you want to import dataset using R scripts, you need to do this.

Run R scripts in Power BI Desktop 

Use R in Power Query Editor 

 

Power BI does not support directly importing R script files from the local.

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Anonymous
Not applicable

Lionel, thanks for your reply, but it doesn't answer my question.

DavisBI
Solution Specialist
Solution Specialist

Hi,

 

Why don't you put the R code directly in the editor of the R custom-visual, but have a separate one on SharePoint?

Anonymous
Not applicable

Hi Davis,

I use the same code for multiple visuals. I keep improving/changing the code, and if its only 1 file, it would be much more easier to trace changes and be sure everything is updated.

When you said 'a separate one' you meant a copy?

Thanks

Susana.

DavisBI
Solution Specialist
Solution Specialist

Got you. You can try to place your .R file locally instead of SharePoint, and then check to see if the problem persists, so you can locate where the problem is. I have tested on my local machine and shared folder, everything is going well.

Anonymous
Not applicable

Hello again,

I'm sorry but I don't understand your proposal.

 

I have tried 3 options:

1) Having the code in a "totally" local path in the visual code. That is "C:/MyCode/script.r"

2) Having the code ina shared folder by Microsoft Teams but saved in my computer. But then, the code in the PBI visual is a local path as above: "C:/MyTeamsFiles/TeamName/PBI/script.r"

3) Having the code in a shared folder in sharepoint and setting http path within the visual. That is: "http:// myself. sharepoint.com /PowerBI /Script_Plot01.r  ")"

 

None of them worked when I published the PBI file.

If you meant something different by 'shared folder', please provide more details on how to implement it.

 

Many thanks,

Susana.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.