问题
I have some tables, e.g. tbl_A, tbl_B & tbl_C that are created in Power BI using R script.
The R script is like this :
df2 <- read.csv("data/customer.csv",quote="")
df2 <- read.csv("data/order.csv",quote="")
#performing various joins / aggregating data
tbl_A <- ...
tbl_B <- ...
tbl_C <- ...
And I choose to load tbl_A, tbl_B & tbl_C when the R script finish executing.
Then those tables are visualized with PowerBI visualization tools such as stacked bar charts. Everything works fine at this point.
The issue I have is that I would need to update the data (because there is new data everyday) without having each time to recreate the charts. I tried re-running the R script and loading tbl_A, tbl_B & tbl_C, but this creates new powerBI tables (tbl_A (2), tbl_B (2) ...) and thus is not updating the data that is used in the charts.
Is there any way to update the data generated by R scripts used in PowerBI visualizations ?
回答1:
Sadly this is not possible as of the current level of R integration in PowerBI.
PowerBI R visualization integration is performed by importing the visual into PowerBI as a static Image. This is explained in the microsoft documentation due to the below limitation:
- R visuals are refreshed upon data updates, filtering, and highlighting. However, the image itself is not interactive and cannot be the source of cross-filtering.
- R visuals respond to highlighting other visuals, but you cannot click on elements in the R visual in order to cross filter other elements.
- Only plots that are plotted to the R default display device are displayed correctly on the canvas. Avoid explicitly using a different R display device.
Basically, PowerBI doesn't incorporate the R graphics device directly into the GUI / visual interface, but rather imports the image. I believe this might be due to how R is integrated. Every R scripts seems to be executed as a self-contained R-session, which closes once the script has finished. Any leftover graphics and data will thus be terminated, and one would have to rerun the script to gain access to the data again.
来源:https://stackoverflow.com/questions/56293403/updating-power-bi-data-generated-by-r-script