Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hi,
I'm testing R visual in PowerBI (I'm a beginner in R). I use map files from an external direectoy which works fine in PowerBI Desktop. However, after uploading the report into PowerBI, I can't access my local files. Not sure how to access these files from PowerBI Service? Could I get them from OneDrive?
I set the files directory this way in my R code:
Any help would be welcome.
Many thanks
If you're ok with using an R script as a query source , you could import the shapefile in an R query and convert the geometry into a well known text (wkt) column (using the sf package's st_as_text() function). This stores the geometry as plain text for each feature.
R Script Query example
library(sf)
shp <- st_read(shapefile)
shp$wkt <- st_as_text(shp$geometry)
When you're ready to do the visual, you can add that wkt column from the PowerBI table to your script visual and convert it back to a spatial format by using st_as_sf(). Make sure your wkt text column is both not summarized and Show items with Missing Data is checked.
Script Visual code to convert wkt column back to sf
library(sf)
dataset_sf <- st_as_sf(dataset, wkt = "wkt", crs = 4326)
I'm assuming your shapefile is WGS84 projection (SRID 4326), but set your CRS argument accordingly to the original projection.
Note that for scheduled refresh on the PowerBI service requires a personal gateway for queries using R scripts as sources.
Hi, @Panou
You can try to change the path to the cloud, or install a personal gateway.
I am not sure about that. You can open a support ticket with MSFT to seek technical support ,they will have better suggestions.
Related document:
https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-r-in-query-editor
Best Regards,
Community Support Team _ Eason
| User | Count |
|---|---|
| 16 | |
| 15 | |
| 12 | |
| 11 | |
| 7 |
| User | Count |
|---|---|
| 44 | |
| 40 | |
| 33 | |
| 29 | |
| 21 |