Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Extending Power BI with Python and R
Extending Power BI with Python and R

Extending Power BI with Python and R: Perform advanced analysis using the power of analytical languages , Second Edition

eBook
$9.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Extending Power BI with Python and R

Configuring R with Power BI

Power BI Desktop is not equipped with the analytical language engines presented in the previous chapter by default. Therefore, it is necessary to install these engines and properly configure Power BI Desktop to correctly interface with them. It is also recommended to install an Integrated Development Environment (IDE), enabling you to work in the way you are most comfortable.

We’ll look at how to get those engines up and running and give you some general guidelines on how to pick the most appropriate one for your needs. After that, we’ll look at how to make these engines interface with both Power BI Desktop and the Power BI service.

Finally, we will give some important tips on how to overcome some stringent limitations of R script visuals within the Power BI service.

In particular, this chapter will deal in detail with the following topics:

  • The available R engines
  • Choosing an R engine to install
  • Installing...

Technical requirements

This chapter requires you to have a working internet connection and Power BI Desktop already installed on your machine. It also requires you to have signed up for the Power BI service in the last part of the chapter (here’s a how-to: http://bit.ly/signup-powerbiservice). A Power BI free license is enough to test all the code in this book, as you will share reports only in your personal workspace.

The available R engines

There is more than one R distribution available on the market that you can use for free for your advanced analytics projects. In this section, we’ll explore the main details of each of them.

The CRAN R distribution

When it comes to installing the R engine, we almost always think of the open source software environment, par excellence, developed by a collective of contributors over the years known as CRAN R, also called base R (https://cran.r-project.org). To be exact, the Comprehensive R Archive Network (CRAN) is a network of web servers and FTP servers around the world whose goal is to preserve multiple identical and up-to-date versions of the R source code and the entire ecosystem of R packages developed by the community, along with all the R documentation.

One of the biggest advantages of CRAN R is its very active community of developers. Their contribution to the creation of new packages on CRAN is invaluable. That’s why if you...

Choosing an R engine to install

Once it is decided that CRAN R is the R distribution to adopt, the first question when installing an R engine is: “Which version should I install? Do I choose the latest one, or do I opt for a previous one?” The usual answer to these kinds of questions is: “It depends!” In our case, the goal is to use the R engine within Power BI, so we need to understand which versions are used by the various products that admit the use of R within them.

The R engines used by Power BI

We saw in Chapter 1, Where and How to Use R and Python Scripts in Power BI, that only two Power BI products are allowed to use scripts in R and Python: Power BI Desktop and the Power BI service (remember that Power BI embedded is implicitly included when talking about the Power BI service). So, the answer “It depends!” has a clearer connotation now: if you need to share your reports with people inside your organization, then you have to...

Installing an IDE for R development

The need to install a state-of-the-art R IDE for the development of code in Power BI comes from the need to have all the tools necessary to identify any bugs and quickly test the results of code chunks on the fly.

TIP

It is strongly suggested to test your R code in the IDE and verify the results before using it in Power BI.

There are many IDEs for R development on the market. Some examples are R-Brain IDE (RIDE), IntelliJ IDEA, and JupyterLab, but it is estimated that over 90% of R programmers use RStudio as their primary IDE because of the countless features that simplify their daily work. For this reason, we suggest that you also use this IDE to test the code you will encounter in this book.

Installing RStudio

Installing RStudio (at the time of writing the chapter, the version is 2022.07.2+576) on your machine is very simple:

  1. Go to https://posit.co/download/rstudio-desktop/ and click the DOWNLOAD RSTUDIO...

Configuring Power BI Desktop to work with R

Once you have installed the R engines necessary for the development of your reports and the RStudio IDE, you must configure Power BI Desktop so that it properly references these tools. This is really a very simple task:

  1. In Power BI Desktop, go to the File menu, click on the Options and settings tab, and then click on Options:
Figure 2.14 – Opening the Power BI Desktop Options and settings window

Figure 2.18: Opening the Power BI Desktop Options and settings window

  1. In the Options window, click on the R scripting tab on the left. The contents of the panel on the right will update, giving you the option to select the R engine to reference and the R IDE to use for R script visuals:
Graphical user interface, text, application  Description automatically generated

Figure 2.19: Choosing the engine and the IDE to work with in Power BI Desktop

  1. As you can see, Power BI Desktop automatically identifies the installed R engines and IDEs. For the moment, select the latest version of the engine (in our case, it is 4.2.2), in order to be aligned...

Configuring the Power BI service to work with R

As you learned in the The R engines used by Power BI section of this chapter, the Power BI service uses different R engines depending on whether the scripts are used in R script visuals or in Power Query for data transformation. In the first case, the engine is pre-installed on the cloud.

IMPORTANT NOTE

If the data sources of your report come exclusively from online services (e.g., Azure SQL Database) or the web, and if the R scripts in your report are used only in the R script visuals, you don’t need to install the data gateway in personal mode to refresh the datasets.

In the second case, or if at least one dataset in your report is fed from an on-premises data source or on an Azure VM, you need to install the on-premises data gateway in personal mode on any machine of your choice in order to make the Power BI service communicate with the R engine you installed on that machine.

Installing the on...

R script visuals limitations

R script visuals have some important limitations regarding the data they can handle, both as input and output:

  • An R script visual can handle a data frame with only 150,000 rows. If there are more than 150,000 rows, only the first 150,000 rows are used and a relevant message is displayed on the image.
  • R script visuals have an output size limit of 2 MB.

You must also be careful not to exceed the 5 minutes of runtime calculation for an R script visual in order to avoid a time-out error. Moreover, in order not to run into performance problems, note that the resolution of the R script visual plots is fixed at 72 DPI.

As you can imagine, some limitations of R script visuals are different depending on whether you run the visual on Power BI Desktop or the Power BI service.

If you think you need to develop reports intended only for Power BI Desktop, without the need to publish them on the service, you can do any of the following...

Summary

In this chapter, you learned about the most popular free R engines in the community. In particular, you learned about the performance advantages introduced by Microsoft in its distribution of R, even if this distribution will be retired in the near future. You also learned how to enhance the standard CRAN R with the oneMKL libraries for multi-threaded calculations.

Taking note of the unique features of Power BI Desktop and the Power BI service, you have learned how to properly choose the engines and how to install them.

You have also learned about the most popular IDE in the R community and how to install it.

In addition, you were introduced to all of the best practices for properly configuring both Power BI Desktop and the Power BI service with R, whether in a development or enterprise environment.

Finally, you learned about some of the limitations of using R with Power BI, knowledge of which is critical to avoid making mistakes in developing and deploying...

Test your knowledge

  1. What are the most popular R engines to date and which of them will be phased out?
  2. What is the most obvious advantage of Microsoft’s R distributions?
  3. Is it possible to introduce the advantage in question 2 for CRAN R as well? If so, can this be done directly from the software installer?
  4. You decide to install the latest available version of CRAN R, and through this, you develop some transformation steps in Power Query. What do you need to be able to publish your report to the Power BI service and allow it to be refreshed regularly?
  5. Suppose you have installed only the R engine mentioned in Question 4 and you also add a plot made with an R script visual to the same report mentioned in Question 4. What are the problems you’ll encounter on Power BI Desktop? What are the problems you’ll encounter when you publish the report to the Power BI service?
  6. Is it possible to refresh datasets of a published report using...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Discover best practices for using Python and R in Power BI by implementing non-trivial code
  • Enrich your Power BI dashboards using external APIs and machine learning models
  • Create any visualization, as complex as you want, using Python and R scripts

Description

The latest edition of this book delves deep into advanced analytics, focusing on enhancing Python and R proficiency within Power BI. New chapters cover optimizing Python and R settings, utilizing Intel's Math Kernel Library (MKL) for performance boosts, and addressing integration challenges. Techniques for managing large datasets beyond available RAM, employing the Parquet data format, and advanced fuzzy matching algorithms are explored. Additionally, it discusses leveraging SQL Server Language Extensions to overcome traditional Python and R limitations in Power BI. It also helps in crafting sophisticated visualizations using the Grammar of Graphics in both R and Python. This Power BI book will help you master data validation with regular expressions, import data from diverse sources, and apply advanced algorithms for transformation. You'll learn how to safeguard personal data in Power BI with techniques like pseudonymization, anonymization, and data masking. You'll also get to grips with the key statistical features of datasets by plotting multiple visual graphs in the process of building a machine learning model. The book will guide you on utilizing external APIs for enrichment, enhancing I/O performance, and leveraging Python and R for analysis. You'll reinforce your learning with questions at the end of each chapter.

Who is this book for?

This book is for business analysts, business intelligence professionals, and data scientists who already use Microsoft Power BI and want to add more value to their analysis using Python and R. Working knowledge of Power BI is required to make the most of this book. Basic knowledge of Python and R will also be helpful.

What you will learn

  • Configure optimal integration of Python and R with Power BI
  • Perform complex data manipulations not possible by default in Power BI
  • Boost Power BI logging and loading large datasets
  • Extract insights from your data using algorithms like linear optimization
  • Calculate string distances and learn how to use them for probabilistic fuzzy matching
  • Handle outliers and missing values for multivariate and time-series data
  • Apply Exploratory Data Analysis in Power BI with R
  • Learn to use Grammar of Graphics in Python

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 29, 2024
Length: 814 pages
Edition : 2nd
Language : English
ISBN-13 : 9781837635863
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Mar 29, 2024
Length: 814 pages
Edition : 2nd
Language : English
ISBN-13 : 9781837635863
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 159.97
Mastering Microsoft Power BI – Second Edition
$49.99
The Definitive Guide to Power Query (M)
$54.99
Extending Power BI with Python and R
$54.99
Total $ 159.97 Stars icon
Banner background image

Table of Contents

24 Chapters
Where and How to Use R and Python Scripts in Power BI Chevron down icon Chevron up icon
Configuring R with Power BI Chevron down icon Chevron up icon
Configuring Python with Power BI Chevron down icon Chevron up icon
Solving Common Issues When Using Python and R in Power BI Chevron down icon Chevron up icon
Importing Unhandled Data Objects Chevron down icon Chevron up icon
Using Regular Expressions in Power BI Chevron down icon Chevron up icon
Anonymizing and Pseudonymizing Your Data in Power BI Chevron down icon Chevron up icon
Logging Data from Power BI to External Sources Chevron down icon Chevron up icon
Loading Large Datasets Beyond the Available RAM in Power BI Chevron down icon Chevron up icon
Boosting Data Loading Speed in Power BI with Parquet Format Chevron down icon Chevron up icon
Calling External APIs to Enrich Your Data Chevron down icon Chevron up icon
Calculating Columns Using Complex Algorithms: Distances Chevron down icon Chevron up icon
Calculating Columns Using Complex Algorithms: Fuzzy Matching Chevron down icon Chevron up icon
Calculating Columns Using Complex Algorithms: Optimization Problems Chevron down icon Chevron up icon
Adding Statistical Insights: Associations Chevron down icon Chevron up icon
Adding Statistical Insights: Outliers and Missing Values Chevron down icon Chevron up icon
Using Machine Learning without Premium or Embedded Capacity Chevron down icon Chevron up icon
Using SQL Server External Languages for Advanced Analytics and ML Integration in Power BI Chevron down icon Chevron up icon
Exploratory Data Analysis Chevron down icon Chevron up icon
Using the Grammar of Graphics in Python with plotnine Chevron down icon Chevron up icon
Advanced Visualizations Chevron down icon Chevron up icon
Interactive R Custom Visuals Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(30 Ratings)
5 star 96.7%
4 star 3.3%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Joseph C. Seroski Apr 01, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is a good reference to understand how you can use Python and R in Power BI. It has a good introduction to getting setup and some great examples as to how you can extend your reports and advance your skills using these two programming languages.I enjoyed this book brings a unique perspective that I haven't seen in many other Power BI books. I am looking forward to getting more into the Python language, and this book will be helpful, especially with all the functionality coming to Fabric. I recommend this book to add another feather to your cap.
Amazon Verified review Amazon
Thomas Rice Aug 03, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
"Extending Power BI with Python and R" is a comprehensive and practical guide for enhancing data analysis capabilities in Power BI. With detailed explanations, practical examples, and step-by-step instructions, this book is an essential resource for anyone looking to integrate R and Python into their Power BI workflows. Whether you're a beginner or an experienced user, this book provides valuable insights and practical tips for maximizing the potential of Power BI. As an avid book worm, having read more than 30 books on the Microsoft Power Platform, this one is a must for anyone that works with Power BI. Highly recommended guys!
Amazon Verified review Amazon
Arden Jul 26, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book author has a strong hold over the Powerbi community and even the technology I believe this book is beneficial for people who have had a strong command over the Power BI, R and Python space because of the diversity it brings throughout the chapters, the most important thing is the journey of different libraries and how it has affected the whole space and how the case studies have been shared throughout the book. Congratulations to the authors for binding in a book of such quality!
Amazon Verified review Amazon
Sruthi Panikar Apr 16, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent book for anyone interested in python and r at the same time loved the book its an amazing title!
Amazon Verified review Amazon
Brady Apr 03, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A great resource for Power BI users aiming to bolster their analytical prowess. The authors offer well-explained and hands-on examples, leading readers through the intricacies of seamlessly integrating Python and R with Power BI.I was particularly drawn to the Python side of this book. I've often found using Python visuals or features in Power BI to be cumbersome. My visuals would load slowly, prompting me to revert to default visuals in Power BI and stick to traditional M query data transformations.This book opened up some possibilities I'd never considered where in the past I'd given up trying to implement. Python has much more appealing visuals and data capabilities but I didn't know how to use it without seemingly bogging down my entire report. As a heavy Power BI user, I got a lot of new ideas to consider from this book.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.