cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

R Scripts and Firewall Error

I've been trying to work with R in Power Query but I keep running into the usual firewall error: 

 

Formula.Firewall: Query 'fDeals' (step 'Run R script') references other queries or steps, so it may not directly access a data source. Please rebuild this data combination.

 

I'm familiar with this error outside of R and I've been habitually using bridge or staging queries to first load my data and then use those as references for merges and anything involving multiple sources. But this error seems to be particularly stubborn when it comes to R scripts. 

 

I'm aware that this can be 'solved' by changing the privacy settings. But is it possible to solve this error without changing privacy level settings? I've looked at other posts on here from people who had the same problem and I didn't find anyone who solved it without changing the privacy level. 

 

I tried Method 2 from this solution: https://sqlitybi.com/formula-firewall-error-referencing-queries-r-python-scripts/

But that didn't actually work. Regardless of whether I'm running a brand new query, or a query made through a function, the moment I add the R script (any R script! even an empty one) I again get the firewall error. So, even with both of these, just leaving the R script empty:

 

let
Source = fDeals,
#"Run R script" = R.Execute("# 'dataset' holds the input data for this script",[dataset=Source])
in
#"Run R script"

---------------------

let
Source = fDeals_function(),
#"Run R script" = R.Execute("# 'dataset' holds the input data for this script",[dataset=Source])
in
#"Run R script"

 

R itself seems to be regarded as a reference to "other queries or steps", which means that invoking it inside any query automatically runs into the firewall error. Would it be possible to invoke R outside of a query and then reference that? Or might placing the R script in a function help?

 

I don't mind changing the privacy levels, but it irks me that I can't find a different solution.

4 REPLIES 4
Highlighted
Community Support
Community Support

Hi @Feldrin ,

 

You could reference the blog: Power Query Errors: Please Rebuild This Data Combination to have a try. The article is a little long-ago. Hope it can help you.

 

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

I read the Excel Guru article but I've only had partial success. 

 

For some queries it works if I move the R script into an earlier query (the staging query) that loads the data from the CSV, rather than placing the R script in a later query that connects to the staging area. Which is odd, because that's not what I'm using staging queries for. 

 

That works but only as long as my staging queries contain all the right data. If I want to use R in a later query, there doesn't seem to be a working solution to get around the firewall error, execpt for switching off the whole privacy thing. 

Highlighted

Hi @Feldrin ,

Sometimes it helps to transform the query into a function (without a parameter) instead.

Go to the advanced editor and add a " () =>" in front of the existing code (so before the "let").

Then your  have to modify the dependent queries by adding parenthesis after the query reference.
So if your R-query (that previously returned a table) is called "MyRQuery", then you reference it like so "MyRQuery()".
This calls the function without a parameter and thereby returning the original result.

 

This sometimes "fools" the engine an will not be checked by the firewall logic.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

New Member

I am having the exact same issue. It seems that R is treated as an external data source, and this really hinders the usefulness of R in Power BI. I have a table that I want to add columns to based off some analysis done in an R script, but there seems to be no way for me to get this to work since I can't change the privacy settings (and I wouldn't want to even if I could)

 

Really hope someone finds a solution here

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors