Power BI Analytics Powered By R Integration

In this article we will have discussion and demo on how to integrate “R” scripts with “PowerBI” using PowerBI R Connector.

In order to utilize this article you should some basic understanding with R Programming.

Before getting into demo lets discuss the concept using following Solution Architecture Diagram-


Data Sources Layer shows few of the available data source that I have tested this solution with

Data Crawlers & Connectors Layer shows a generic set of Data Connectors provided by Reporting Engines and Custom Crawlers.

CSV Raw Data Sources shows the set of output files that can be used as input files by R APIs

R Programming Interface shows the R APIs and & Packages that can be utilize to perform statistical operations on the incoming data and generated a meaningful output.

Computed/Analytical Data Output shows the Output files generated by R APIs

Reporting Engines shows a couple of famous reporting engines that can be utilized to develop reports based on the input received from R APIs

In this demo I am not covering the Crawl process since there is nothing new about it. I am considering a CSV Raw Data Source is available to be consumed by R APIs as shown below-

In this raw data source we have some data related to the File Shares. It is showing number of files that are available within each file share for a specific quarter.


Now the scenario is to consume this data for developing trend analysis report and the obvious problem is that it is not in desired format to be consumed directly reporting engine.

That’s where we are utilizing R Programming Language which is quite in fashion these day and is well known for its Statistical Capabilities.

Though I am not displaying any hefty R Code here but rest assured you are all free to take this data transformation up to any level as per your requirements.

In the following R snippet I am reading data from CSV Files and group it based on the Quarter Column to display quarter wise Files Count.


For example this could be helpful if we need to develop some trend analysis on sizing capabilities of a disk.

You can see the outcome of this script as highlighted below-

Column “Group.1” shows Quarters & Column “x” shows total number of files per quarter


Once the R script is ready and validated we can start designing report using any of the report designers support R connectors or if they don’t we can save the R output as CSV/Database file and can feed the report designer with this output.

For this demo I am using PowerBI and interesting thing about it is having inbuilt R connector for rendering R scripts with in the report designer.

  • Launch Power BI desktop application


  • Click on Get Data Menu -> Click on More…


  • Select “Other” category of available connectors
  • Select R Script connector under “Other”
  • Click Connect


  • Paste the R Script in the script designer
  • Click OK.


As soon as script designer able to parse the script, it will show you all the possible outputs that were stored in R Variables inside the script

  • Select source as required
  • Click Load to load the required data source in designer memory


In the report designer we can see data source and its related fields listed under Fields section as highlighted

Under Visualizations we can see the possible Charts/Graphs available to design the dashboard.

Choose as per requirement and design the report


Here is demo dashboard that I have developed using this data source.


The important take away from this demo is to understand the right selection of technology and possibility of technology fusion to get desired output.

Hope you find it helpful.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s