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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
luxpbi
Helper V
Helper V

R script visual not working in Service

Hi, 

 

I've created a R visual that load data from RData Files. Everything is working fine in desktop. 

 

But I have problem when I upload it to the cloud, the script doesn't found the path of the files because they are in local ... obiously. 

How can I solve this?

 

Thanks in advance!

7 REPLIES 7
Stachu
Community Champion
Community Champion

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



Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Hi @Stachu,

 

The problem is just with the visual. 

I attach photos in case it helps to see the problem.

Captura.PNGCaptura2.PNG

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

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.

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



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi Tom, 

 

Thank you very much for your answer. 

 

So I think for the moment the only solution in to make it work in Power BI Desktop.

 

Do you know if you can manage permisions in the desktop ? I don't want user to be able to manipulate data for example...

 

Regards.

Anonymous
Not applicable

Hey @luxpbi

 

I'm jumping over to this thread as I saw you opened a new question specific to getting this working in the service. Tom's idea to collapse and expand is really neat. I also wanted to ask, is your R visual performing any aggregations that you could perform in your data model before importing into the visual? 

 

Thanks,

Parker

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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