Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs

Power BI R Script

by suresh

Power BI R Script allows using R visuals or R charts inside your Power BI dashboard. Using R script inside the Power BI is very helpful for the data scientists to place their work in one place.

In this section, we show you how to create a chart using Power BI R Script with example. For this Power BI R Script demonstration, we are going to use the Faithful CSV file created by R studio.

I suggest you refer R Programming to understand the code that we used in this Power BI article.

Power BI R Script 1

Create a Power BI R Script Visual

In Power BI, you can use this R Script Visual to create R Charts inside a Power Bi dashboard.

Power BI R Script 2

First, click on the R Script Visual under the Visualization section. It automatically creates an R Chart with an R script editor, as shown in the below screenshot.

You have to use this R script editor window to write R script.

Power BI R Script 3

Before you start writing R code, you have to create a data set. It can be done by dragging the required fields to the Values section. For this demo, let me drag eruptions and waiting columns to the Values section.

Power BI R Script 4

As you can see from the above screenshot, Power BI has automatically generated a data set for you. Now, you have to use this data set to create your R visual.

Here, we used ggplot2 to create 2D scatter plot. I suggest you refer, Create a Scatter Plot article to understand this code.

library(ggplot2)
ggplot(dataset, aes(x = eruptions, y = waiting))  +  
     geom_point() + 
     geom_density_2d()

Once you finished writing your script, click the Run button

Power BI R Script 5

From the screenshot below, you can see the R Chart.

Power BI R Script 6

Like any other chart in Power BI, you can apply filters on the R chart as well. To demonstrate the Power BI R script filters, let me create a table first.

Power BI R Script 7

We created a column chart, as well.

Power BI R Script 8

I think there is too much data in the table to apply filters. So, let me create a cluster.

Power BI R Script 9

We are leaving the default settings

Power BI R Script 10

As you can see, it has created two clusters. Next, we replaced the Sno with the Cluster column in a Table

Power BI R Script 11

Let me select the Cluster 1. From the screenshot below, you can see that the R visual is filtering.

Power BI R Script 12

Try with the other cluster too

Power BI R Script 13

Create a Power BI R Script Visual 2

In Power BI, you can also create an R visual with default datasets available in R. To demonstrate the same, we are using the Diamonds data set.

library(ggplot2)
ggplot(diamonds, aes(x = carat, y = price, color = cut))  +  
       geom_point() + 
       geom_smooth(method = "auto", se = FALSE) +  
       scale_color_manual(values = c("orchid", "chocolate4",   
                                 "goldenrod2", "tomato2", "midnightblue"))

From the screenshot below, you can see the R Script in the report.

Power BI R Script 14

Placed Under: Power BI

  • Install Power BI Desktop
  • Connect Power BI to SQL Server
  • Add Rename and Duplicate Pages
  • Connect to Multiple Excel Sheets
  • Get Excel Data to Power BI
  • Get Text File Data to Power BI
  • Load Data from Multiple Sources
  • Remove Power BI Table Columns
  • Create Power BI Bins
  • Power BI Joins
  • Change Column Data Types
  • Combine Multiple Tables
  • Power BI Clusters
  • How to Enter Data into Power BI
  • How to Format Dates in Power BI
  • Create Power BI Groups
  • Create Power BI Query Groups
  • Create Power BI Hierarchy
  • Power BI Pivot Table
  • Power BI Unpivot Table
  • Rename Power BI Table Names
  • Rename power bi column names
  • Split Columns in Power BI
  • Remove reorder power bi column
  • Power BI Area Chart
  • Format Power BI Area Chart
  • Power BI Bar Chart
  • Format Power BI Bar Chart
  • Power BI Clustered Bar Chart
  • Clustered Column Chart
  • Create a Power BI Card
  • Format Power BI Card
  • Create Power BI Multi-Row Card
  • Format Power BI Multi-Row Card
  • Power BI Column Chart
  • Format Power BI Column Chart
  • Power BI Donut Chart
  • Format Power BI Donut Chart
  • Power BI Funnel Chart
  • Format Power BI Funnel Chart
  • Power BI Heat Map
  • Power BI Line Chart
  • Format Power BI Line Chart
  • Line & Clustered Column Chart
  • Format Line & Clustered Column
  • Line & Stacked Column Chart
  • Format Line & Stacked Column
  • Power BI Matrix
  • Format Power BI Matrix
  • Power BI Table
  • Format Power BI Table
  • Add Data Bars to Power BI Table
  • Add alternate Table Row Colors
  • Power BI Pie Chart
  • Format Power BI Pie Chart
  • Power BI Ribbon Chart
  • Format Power BI Ribbon Chart
  • Power BI Treemap
  • Format Power BI TreeMap
  • Power BI Scatter Chart
  • Format Power BI Scatter Chart
  • Power BI Stacked Area Chart
  • Power BI Stacked Bar Chart
  • Format Stacked Bar Chart
  • Power BI Stacked Column Chart
  • Format Stacked Column Chart
  • Power BI Waterfall Chart
  • Format Power BI Waterfall Chart
  • Power BI 100% Stacked Bar Chart
  • 100% Stacked Column Chart
  • Create a Power BI Map
  • Format Power BI Map
  • Power BI Filled Map
  • Format Power BI Filled Map
  • Power BI Basic Filters
  • Power BI Slicer
  • Power BI Top 10 Filters
  • Power BI Drill through Filters
  • Power BI Filters on Measures
  • Power BI Advanced Filters
  • Power BI Report Level Filters
  • Power BI Page Level Filters
  • Power BI Calculated Columns
  • Add Conditional Column
  • Create Power BI Custom Column
  • Power BI Calculated Measures
  • Power BI Calculated Tables
  • Power BI DAX String Functions
  • Power BI DAX Math Functions
  • DAX Trigonometric Functions
  • Power BI DAX Date Functions
  • Power BI DAX Logical Functions
  • Power BI DAX Agg. Functions
  • Power BI Dashboard Introduction
  • Power BI Dashboard Settings
  • Power BI Dashboard Actions
  • Delete Power BI Dashboard
  • Subscribe Power BI Dashboard
  • Add Web Content to Dashboard
  • Add Image to Dashboard
  • Add video to power bi dashboard
  • Add Title to Power BI Dashboard
  • Pin Workbooks to Dashboard
  • Register to Power BI Service
  • Connect to Power BI Service
  • Create Power BI Workspace
  • Share Power BI Workspace
  • Create a Report in Workspace
  • Rename a Report in Workspace
  • Rename a Dataset in Workspace
  • Quick insights in Power BI
  • Get insights in Power BI
  • Publish power bi desktop report
  • Upload Power BI Workbooks
  • Upload Excel Files to Dashboard
  • Edit Power BI App
  • View Published Power BI App
  • Publish Power BI App
  • Share Power BI Dashboard
  • Share Power BI Workspace
  • Share Power BI Report
  • Power BI Q&A
  • Power BI Q&A Advanced
  • Customize Q&A Suggestions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy