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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
PaulWild
New Member

Is it possible to use R scripts as a data source when publishing a file to the PowerBI service?

Hello,

I have a PowerBI file that uses R scripts as a data source. The scripts access a database, query and manipulate a few existing tables, and then imports the resulting table into PowerBI. The scripts run well on PowerBI Desktop but unfortunately when attempting to publish this to the PowerBI service, I am running into a gateway issue. I am using an On-premise data gateway that can successfully connect to the SqlServer and other files, but spits back an error related to R:

 

PaulWild_0-1712334231861.png

 

 

Scouring the PowerBI support forums and resources, everything that I have found only talks about generating visuals using R, and I have yet to find a resource talking about using R scripts as a datasource for PowerBI. I found this stack overflow thread from 2019, but have yet to find anything more recent.

 

 

Is it possible to use R scripts as a data source when publishing a file to the PowerBI service?

1 REPLY 1
johnbasha33
Super User
Super User

@PaulWild 

Using R scripts as a data source in Power BI can be a bit trickier when it comes to publishing to the Power BI service, especially if you're encountering gateway-related issues. Here are some considerations and potential solutions:

  1. Gateway Configuration: Ensure that your on-premises data gateway is correctly configured and running. The gateway should have access to the database that your R scripts are querying and should be able to execute those scripts successfully.

  2. Gateway Version: Check if you're using the latest version of the on-premises data gateway. Sometimes, newer versions include bug fixes and improvements that can resolve compatibility issues.

  3. R Runtime Configuration: Power BI service uses a different environment than Power BI Desktop, which may affect how R scripts are executed. Make sure that your R scripts are compatible with the environment in which they are being executed, and that any necessary R packages are installed on the server running the on-premises data gateway.

  4. Data Privacy Settings: Power BI service enforces data privacy settings to prevent data from being sent to external sources without user consent. Ensure that your R scripts and data connections comply with Power BI's data privacy rules.

  5. Troubleshooting: Use diagnostic tools provided by Power BI service and the on-premises data gateway to troubleshoot the issue. Check gateway logs, error messages, and event logs for any clues about what might be causing the problem.

  6. Alternative Approaches: If you're unable to resolve the gateway issue, consider alternative approaches for using R scripts in Power BI. For example, you could pre-process your data using R scripts outside of Power BI and then import the resulting dataset into Power BI as a static data source.

    Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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