Skip to main content

Power BI

Under Review

Pass data from another source as input to the R.Execute () function

Vote (23) Share
David E's profile image

David E on 23 Dec 2015 01:54:41

The R.Execute () Power Query function only allows you to use R for ingesting data. Ideally, make R.Execute () more powerful by making it a data transformation function as well as data source. Let data be loaded from other sources, and then R.Execute () could be called in a subsequent step in the Power Query query.

let
Source = Excel.Workbook(File.Contents("C:\[...].xlsx"), null, true),
Custom1 = R.Execute("df<-data.frame(Source) [...]")
in
Custom1

Transformations could all be done in R first, but it's slower in general, and you lose the convenience of blending data in Power BI itself.

Comments (6)
David E's profile image Profile Picture

hugoberry on 16 Aug 2020 03:56:08

RE: Pass data from another source as input to the R.Execute () function

I think this feature has already been implemented. Here is an example

let
Source = #table({"num"},List.Accumulate({1..10},{},(s,c)=>s&{{c}})),
RScript = R.Execute("df<-dataset#(lf)df$fact<-factorial(df$num)",[dataset=Source]),
out = RScript{[Name="df"]}[Value]
in
out

David E's profile image Profile Picture

David E on 16 Aug 2020 03:54:03

RE: Pass data from another source as input to the R.Execute () function

AWESOME! It's working in Desktop!

David E's profile image Profile Picture

Imke Feldmann on 16 Aug 2020 03:53:53

RE: Pass data from another source as input to the R.Execute () function

If I'm not mistaken we could use this functionality also to push data from Power BI to Excel. Although the ability to connect to a PBI model via Excel is great, this is a pull-mechanism and sometimes there is a requirement to push data in a table-format to Excel. There are also requirements to export more than 1.1 Mio rows - to csv or text - R could be used as a workaround for these cases. At the moment the only way to go is via a visualisation and there we're experiencing a row-limit of 150k. Folks sometimes like to use the transformations they've done in PBI (desktop!) not only in visualisations there, but also (reuse) for other tasks.

David E's profile image Profile Picture

ankit patira on 16 Aug 2020 03:53:50

RE: Pass data from another source as input to the R.Execute () function

Really great feature to have.

David E's profile image Profile Picture

J on 16 Aug 2020 03:53:11

RE: Pass data from another source as input to the R.Execute () function

I second this idea. This would make Power Query a real winner

David E's profile image Profile Picture

Andrea Cuneo on 16 Aug 2020 03:52:34

RE: Pass data from another source as input to the R.Execute () function

This is blocking for us since R doesn't support our data sources natively while Power BI does.