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.
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.
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.
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.
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)