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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
troyhimes
Resolver I
Resolver I

R script not working in Service

 

    #"Removed Duplicates" = Table.Distinct(#"Changed Type2", {"Column X"}),
    #"Run R script" = R.Execute("# 'dataset' holds the input data for this script#(lf)#(lf)write.csv(dataset, file = ""C:/Users/userX/Downloads/data.csv"")",[dataset=#"Removed Duplicates"]),
    ReturnValue = #"Removed Duplicates"
in
    ReturnValue

 

 

I use R script to export data to a csv file which works great when I open the file in desktop.  When published to the service it doesn't function and there are no errors returned.   I've tried changing the file destination to a public network but doesn't seem to change the outcome.  Any ideas? 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @troyhimes ,

 

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.

 

Please see:

Export the data - considerations-and-limitations 

Create and use R visuals in Power BI 

 

As a workaround,you may refer to : Export CSV file to OneDrive Using R Scripting in Power BI Service 

 

Hope it helps,


Community Support Team _ Caitlyn

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @troyhimes ,

 

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.

 

Please see:

Export the data - considerations-and-limitations 

Create and use R visuals in Power BI 

 

As a workaround,you may refer to : Export CSV file to OneDrive Using R Scripting in Power BI Service 

 

Hope it helps,


Community Support Team _ Caitlyn

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

TomMartens
Super User
Super User

Hey @troyhimes ,

 

to execute R-Script from inside Power Query you need an on-premises gateway installed in Personal mode.

It's also necessary that R is installed on the same machine as the gateway.

I assume this thread provides some useful links: https://community.powerbi.com/t5/Desktop/Refreshing-R-Script-on-Personal-Gateway/td-p/1064902

 

Here you will find more information about the personal gateway: https://docs.microsoft.com/en-us/power-bi/connect-data/service-gateway-personal-mode

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Thanks for the links @TomMartens but the on premises gateway in Personal Mode and R are both installed on my computer.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.