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
pankaj1408
New Member

Error while exporting data in csv file using R script in power bi service

Hi ,

When i am trying to export powerb dataset into a csv file using R script(shown below)

filename="D:\\BIR\\bitest3.csv"
#dataset <- data.frame(Id, Name)
# dataset <- unique(dataset)
write.csv(dataset,filename)
 
I am able to generate file when i run power bi desktop but when i try to run the same file using power bi services 
i am getting permission denied error, we have tried give all the permission to this folder, file etc.
We have checked gateway dataconnection setting as well, everything is working fine.
PFB error message from power bi services.
 
Error in file(file, ifelse(append, "a", "w")) : cannot open the connection In addition: Warning message: In file(file, ifelse(append, "a", "w")) : cannot open file 'D:\BIR\bitest3.csv': Permission denied
Please try again later or contact support. If you contact support, please provide these details.
Activity IDd1ed46a2-b6d3-401e-8cf8-b28d8dd9f593
Request ID9bf14fcd-ec9c-500a-f9f7-e85facebf04c
Correlation ID32cea294-6fc1-2b12-9147-e4ebac8b1d0f
TimeSun Jul 14 2019 15:48:26 GMT+0530 (India Standard Time)
Version13.0.9933.305
Cluster URIhttps://wabi-india-central-a-primary-redirect.analysis.windows.net

Thanks
Pankaj

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @pankaj1408 ,

For security/permission reasons, you can't execute r script(power bi service side) to loading external data source or do export/import operations on specific path.

Creating R visuals in the Power BI service

Regards,

Xiaoxin Sheng

View solution in original post

4 REPLIES 4
kyin0007
Frequent Visitor

here is my r script, 

# 'dataset' holds the input data for this script
output <- as.data.frame(dataset)

currentDate <- Sys.Date()
csvFileName <- paste("C:/Users/
WIP1_", currentDate, ".csv", sep="")

write.csv(dataset,
file = csvFileName, sep=",",
row.names=F)

kyin0007
Frequent Visitor

i have the same problem even in the desktop version

Anonymous
Not applicable

Hi @pankaj1408 ,

For security/permission reasons, you can't execute r script(power bi service side) to loading external data source or do export/import operations on specific path.

Creating R visuals in the Power BI service

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

@Xiaoxin,

 

In my case I have a dataset created from dataflow and R script to export it to CSV, upload it to SharePoint. This works fine on Power Bi desktop. Are you saying this will not work on Power BI services due to security reasons ?

 

Regards,

Jyoti Pawar

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.