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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

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.

5 REPLIES 5
Anonymous
Not applicable

Hello,

2 years down the line, same issue... does anyone have any solution to it?

By the way I also tried the technique presribed here, and in some of the blogs, of wrapping the original source query in Function and then calling R script in a new query based on function. Below is my query dependency diagram.

Original source is ODBC connection of AWS Simba Athena user DSN.

nirmit27_0-1646211669489.png

Thanks

 

Anonymous
Not applicable

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

v-xuding-msft
Community Support
Community Support

Hi @Anonymous ,

 

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.
Anonymous
Not applicable

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. 

Hi @Anonymous ,

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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