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
OPS-MLTSD
Post Patron
Post Patron

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

Hello,

 

I am trying to import an R script into power BI, I tested the script in R and it works perfectly fine but when I try to import it to power bi using "get data -> r script", this is the message I get:

 

OPSMLTSD_0-1686683285215.png

 

 

Here is the script I try to load into R script in Power BI:

 

 

actualLibPaths <- as.data.frame(.libPaths(.libPaths()[3]))
source(here::here("subfolder1", "subfolder2", "subfolder3", "subfolder4", "subfolder5", "script.R"))


output <- script_last %>%
group_by(actual_month) %>%
summarise(location = "main",
total_all = sum(total)
) %>%
bind_rows(script_last) %>%
mutate(id = row_number())

 

It is not a big script and nothing too complicated. I ran it in R before loading into power bi and everything is working just fine in R, however, I am not sure why i am getting that message, everything is set up just fine in power bi:

 

OPSMLTSD_2-1686662512783.png

 

 

 

if someone could please help, I would really appreciate that

 

 

EDIT:

I changed my script in r script editor in power bi to just this:

 

source("C:/Users/MyUserName/folder1/subfolder1/subfolder2/subfolder3/subforlder4/script.R")

I tested it in R first and it works just fine but when I import to r script in power bi, this is the new message I get:

 

OPSMLTSD_0-1686757793142.png

 

We encountered an error while trying to connect. Details: "SYMSXP"

 

I have no idea how to solve this, the error message is not very helpful, if someone could please help, I would appreciate that

 

4 REPLIES 4
Anonymous
Not applicable

HI @OPS-MLTSD,

I'd like to suggest you double-check the current account and permission configurations to ensure if you and power bi desktop client have enough permissions to access initiation path/folder of R script.

Regards,

Xiaoxin Sheng

@Anonymous  thanks, is there a way I can check?

Anonymous
Not applicable

HI @OPS-MLTSD,

Normally you can enter the parent folder of the configured path and right click on the folder and choose 'properties'. Then you can navigate the 'security' tab to check corresponded permission setting of different users.

How to Set File and Folder Permissions in Windows (online-tech-tips.com)

Regards,

Xiaoxin Sheng

@Anonymous  thank you I will try this solutiona nd get back.

 

Meanwhile, I figured out why I am getting this error message:

We encountered an error while trying to connect. Details: "SYMSXP"

 

It is because I have a package in my r script not supported as part of the R packages supported by Power BI: Learn which R packages are supported - Power BI | Microsoft Learn

The package is called fpp3 - used for time series forecasting.

 

If anyone could tell me how I can contact Power BI - R support to get the package added, that would be much appreciated

 

 

 

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.