Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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!
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
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.
Lionel, thanks for your reply, but it doesn't answer my question.
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?
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.
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.
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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
40 | |
21 | |
20 | |
15 | |
15 |
User | Count |
---|---|
27 | |
20 | |
18 | |
16 | |
14 |