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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors