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

effc1758 1391-4be2-bfd5-451f15134b20 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

587423a6 0263-44d8-8d7f-a9a5326d0017 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

2bc2d404 55c8-ea11-a812-000d3a9b112e 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

0f511688 3a4a-e811-a974-000d3a1ab978 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

8f1da1e0 dd29-4760-b8fb-1ad13aabe070 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

a91a542d cca4-4c9a-8255-10e1af5caf5a 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.