This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
With the latest release of Power BI Desktop, you can now run R scripts directly in Power BI Desktop. To celebrate this new functionality, we’re creating a series of blog posts that show you how to use this new functionality, with some hands-on examples. By the end of this blog post, you learn how you can consume your R code in Power BI, and take full advantage of this built-in functionality in Power BI. To illustrate how this works, we look at a simple example where we create a forecast in R, and consume it in Power BI.
Using the R Script data connector in Power BI Desktop, you can now take your existing R code and use Power BI to visualize it, share it, and operationalize it.
Since I’m an R user, I already have a local R engine installed, and an existing R script. My R code reads time series data from a local CSV file that contains daily website traffic. It then creates a forecast (using Holt-Winters method) and 2 data frames are created – for actual and predicted data.
2) Now that I know my script runs successfully, I open Power BI Desktop and, select Get Data > Others > R Script from the ribbon.
3) The forecast dialog appears. I simply copy and paste my R script into the R script window, and select OK.
4) The script executes on the R which I have previously installed myself on my computer. The resulting data frames are loaded into the data model. 5) Once the data is loaded into Power BI Desktop, I can leverage its full power. For example – I created a line chart showing the prediction. 6) Now I have a report which is built on top of an R script data connection. I will publish it to the Power BI service, and share it with my peers.Since I expect the input data to the forecast to update daily, I will schedule a refresh over this dataset.
Note: In order to enable refreshing “R Script” connections - confirm you have the latest version of the personal gateway is installed on the computer running the R script, and ensure the personal gateway is configured with the account that has access to the data being refreshed.
I first configure the connection type, as shown in the following image:
And then I schedule the refresh. Once the refresh is scheduled, every morning at 10:00AM this R script will execute on my local R environment, and the refreshed output will be updated in the Power BI service, so my peers always see the updated results.You also saw the step-by-step process of how this is done, with an example of time series forecasting.
In future blog posts, we’ll get into more detail (and more cool things you do) with R and Power BI. There is just so much you can do with R - so stay tuned for more on this! If you want more information on R scripts in Power BI Desktop, take a look here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.