Forum Discussion
R script visual not working in Service
I think you need data gateway so the service can get access to your local files
https://docs.microsoft.com/en-us/power-bi/refresh-desktop-file-local-drive
Hi Stachu,
The problem is just with the visual.
I attach photos in case it helps to see the problem.
- TomMartens8 years agoSuper User
Hey,
as far as I understand your R script that works perfectly in your Power BI Desktop contains basically these 3 steps:
- read source data
- prepare the data
- create the visual
these 3 steps in one single r script will wonk in PBI Desktop.
But this will not work in the service, the reason is:
R script visuals or Custom Visuals (R based) are running in a kind of sandbox and are not allowed to access "external" ressources.For this reason you have to split your R scipt.
- reading the source data (this can be done by using the R script source connection)
this step has to return a table object to the Power BI data model
be aware that it is necessary to install the on-premises data gateway in personal mode - create the r visualbased on the Power BI table
The data preparation (if necessary) can either be done in the first step or also in the r script that creates the visual
This link will maybe also useful:
https://docs.microsoft.com/en-us/power-bi/desktop-r-in-query-editor
Regards,
Tom
- luxpbi8 years agoHelper V
Hi TomMartens,
First of all, thank you for your answer.
If I put the data in my Power BI model with an R script as data source, I have a limitation in the R visual script of 150.000 rows of data isn't it?
The fact that my data is out of Power BI and I it's in my R script is to avoid that limitation.
That's the way my R script works.
- Load data
- Prepare data
- Pass parameters with Power BI (the idea is that the script will change with the inputs of the users)
- Create the visual
As I said in Power BI Desktop everything is working fine. The problem ocurs in the service, I understand the sandbox you are talking about, but is the a way to solve my situation?
Thanks again.
Regards.
- TomMartens8 years agoSuper User
Hey,
okay now it becomes clearer ...
Unfortunately there is this data point limit of 150000.
If you can't "compress" the number of data points there will be no solution.
Once I had been challenged with a similar problem ...
Lets assume your dataset looks like this
A | this | 1
A | this | 1
A | that | 2
I prepared the dataset that I passed to the R script visual in this way (I collapsed the dataset)
A | this | 1 | 2
A | that | 2 | 1
Inside the R script visual I then "expanded" the dataset again. I used the R package data.table for the collapsing and also for the expansion.
if you have to "visualize" more than 150000 datapoints at the same time, also considering filtering the dataset / the dataframe by Power BI Slicer and you are not able to collapse the dataset/dataframe that is passed to the R script visual, there is no solution - unfortunately.
Regards,
Tom