Forum Discussion
R script with several dataframes
- 9 years ago
When using R scripts in Power BI Desktop, it will generate one dataset for each data frame. If you generate multiple data frames with single R script, it will generate multiple datasets and repeat the R script for each dataset. We can't access the original script and make changes applied to all datasets by updating only one script.
Also when refreshing dataset, it will run the R script again for each dataset which is very inefficient in your scenario. So I suggest you use multiple R scripts and each of them only creates one data frame.
Reference:
Running R Scripts in Power BI DesktopRegards,
When using R scripts in Power BI Desktop, it will generate one dataset for each data frame. If you generate multiple data frames with single R script, it will generate multiple datasets and repeat the R script for each dataset. We can't access the original script and make changes applied to all datasets by updating only one script.
Also when refreshing dataset, it will run the R script again for each dataset which is very inefficient in your scenario. So I suggest you use multiple R scripts and each of them only creates one data frame.
Reference:
Running R Scripts in Power BI Desktop
Regards,
- jb1t9 years agoAdvocate I
I have the same issue... it isn't effiencient to create N number scripts for each data.frame as I'd have to reproduce the same logic and pull data from data sources multiple times...
- kcwilsonii4 years agoHelper I
Exact same problem, My script works great, but now I have to modify 20 scripts rather than just one.
Tried importing the main table and modifying the script to run against that table, but this results in 20 tables
that do not get added to the model like they should. Instead they sit in a sub table that I can click on the table link, but nothing
is available for visual and it ends up somehow trashing the date field.
Other workaround is to output all the data frames to text files and then link the PowerBI to that. But that seems rather redundant.
Is there a better way?