Reader small image

You're reading from  Microsoft Power BI Quick Start Guide - Third Edition

Product typeBook
Published inNov 2022
PublisherPackt
ISBN-139781804613498
Edition3rd Edition
Right arrow
Authors (4):
Devin Knight
Devin Knight
author image
Devin Knight

Devin Knight a Microsoft Data Platform MVP and the President at Pragmatic Works Training. At Pragmatic Works, Devin determines which courses are created, delivered, and updated for customers, including 15+ Power BI courses. This is the tenth SQL Server and Business Intelligence book that he has authored. Devin often speaks at conferences such as PASS Summit, PASS Business Analytics Conference, SQL Saturdays, and Code Camps. He is also a contributing member to several PASS Virtual Chapters. Making his home in Jacksonville, FL, Devin is a contributor at the local Power BI User Group.
Read more about Devin Knight

Erin Ostrowsky
Erin Ostrowsky
author image
Erin Ostrowsky

Erin Ostrowsky is a creative and passionate lifelong learner. She began her career as a business journalist and researcher and found herself drawn to the power of beautifully visualized data analysis. After living overseas, Erin returned to the USA looking to marry her communication background with a technical focus and found a life changing opportunity to work as a trainer for Pragmatic Works where she focused on creating new educational materials and delivering Power BI training around the country. Erin focuses on the Power Platform tools and loves working on teams to build business intelligence solutions that businesses use and enjoy.
Read more about Erin Ostrowsky

Mitchell Pearson
Mitchell Pearson
author image
Mitchell Pearson

Mitchell Pearson has worked as a Data Platform Consultant and Trainer for the last 8 years. Mitchell has authored books on SQL Server, Power BI and the Power Platform. Data Platform experience includes designing and implementing enterprise level Business Intelligence solutions with the Microsoft SQL Server stack (T-SQL, SSIS, SSAS, SSRS), the Power Platform and Microsoft Azure. Mitchell is very active in the community: Running the local Power BI User Group, presenting at user groups locally and virtually, and creating YouTube videos for MitchellSQL
Read more about Mitchell Pearson

Bradley Schacht
Bradley Schacht
author image
Bradley Schacht

Bradley Schacht is a principal program manager on the Microsoft Fabric product team based in Saint Augustine, Florida. Bradley is a former consultant and trainer and has co-authored five books on SQL Server and Power BI. As a member of the Microsoft Fabric product team, Bradley works directly with customers to solve some of their most complex data problems and helps shape the future of Microsoft Fabric. Bradley gives back to the community by speaking at events, such as the PASS Summit, SQL Saturday, Code Camp, and user groups across the country, including locally at the Jacksonville SQL Server User Group (JSSUG). He is a contributor on SQLServerCentral and blogs on his personal site, BradleySchacht.
Read more about Bradley Schacht

View More author details
Right arrow

Data Transformation Strategies

Within any business intelligence (BI) project, it is essential that the data you are working with has been properly scrubbed to ensure accurate results on your reports and dashboards. Applying data cleansing business rules, also known as transformations, is the primary method for correcting inaccurate or malformed data, but the process can often be the most time-consuming part of any corporate BI solution. However, the data transformation capabilities built into Power BI are both very powerful and user-friendly. Using the Power Query Editor, tasks that would typically be difficult or time-consuming in an enterprise BI tool are as simple as right-clicking on a column and selecting the appropriate transform for the field. While interacting with the user interface, the Power Query Editor automatically writes queries using a language called M behind the scenes.

Through the course of this chapter, you will explore some of the most common features of the...

Which should I choose?

Now that you have learned about the three different ways to connect to your data, you are left wondering which option is best for you. It's fair to say that the choice you make will really depend on the requirements of each individual project you have.

To summarize, some of the considerations that were mentioned in this chapter are listed in the following table:

Consideration Import Data DirectQuery Live connection
Best performance Yes No Yes
Best design experience Yes No No
Best for keeping data up to date No Yes Yes
Data source availability Yes No No
Most scalable No Yes Yes

Some of the items you'll consider may be more important than others. So, to make this more personal, try using the Data Connectivity - Decision Matrix file that is included with this book. In this file, you can rank (from 1 to 10) the importance of each of these considerations to help you choose which option is best for you.

Since the Import Data option presents the...

Summary

Often Power BI developers have questions concerning various data sources and what unique challenges come with each connection. The great news is once you have established a connection to your data source, regardless of which one it is, everything after that point typically follows that same pattern of steps. The point is don’t let any one data source overly intimidate you. Once you connection to it, the rest of your Power BI solution design will follow the same processes mentioned earlier in this chapter of data discovery, data modeling, data visualization, and sharing.

Power BI provides users with a variety of methods for connecting to data sources with natively built-in data connectors. The connector you choose for your solution will depend on where your data is located. Once you've connected to a data source, you can decide on what type of query mode best suits your needs. Some connectors allow for little to no latency in your results with options like DirectQuery...

Advanced data transformation options

Now that you should be more comfortable working within the Power Query Editor, let’s take the next step and discuss more advanced options. Often, you will find the need to go beyond these basic transforms when dealing with data that requires more care. In this section, you will learn about some common advanced transforms that you may have a need for, which include Conditional Columns, Fill Down, Unpivot, Merge Queries, and Append Queries.

Add Conditional Columns

Using the Power Query Editor Conditional Columns functionality is a great way to add new columns to your query that follow logical if/then/else statements. This concept of if/then/else is common across many programming languages, including Excel formulas. Let’s review a real-world scenario where you would be required to do some data cleansing on a file before it could be used. In this example, you will be provided with a file of all the counties in the United States...

The R programming language

R is a very powerful scripting language that is primarily used for advanced analytics tools but also has several integration points within Power BI. One such integration is the ability to apply business rules to your data with the R language.

Why is that important? Well, with this capability, you can extend beyond the limits of the Power Query Editor and call functions and libraries from R to do things that would not normally be possible. In the next two sections, you will explore how to set up your machine to leverage R within Power BI and then walk through an example of using an R script transform.

There are many additional books and references you can read to learn more about the R scripting language, but for the purposes of this book, our goal is to inform you of what is possible when R and Power BI are combined.

Installation and configuration

To use R within Power BI, you must first install an R distribution for you to run...

AI Insights

As you learned in the previous section, Power BI integrates and takes advantage of outside tools to enhance the capabilities within itself. That continues to be the case with the AI Insights features. Leveraging the AI Insights capabilities gives you the ability to tap into core features and algorithms within Azure Cognitive Services and expose them within Power BI. So how can this be useful to you?

Imagine you work for a company that runs a vacation rentals website. Customers can book trips and post reviews of them on your website. With thousands of customers and hundreds of rental homes, it can be difficult to manage all the reviews that come in to make sure your locations are all meeting the standards your customers expect. With AI Insights you can run algorithms that can perform sentiment analysis, key phrase extraction, language detection, and even image tagging.

So, if you have international customers that post reviews, you can use language detection to understand...

The M formula language

The Power Query Editor is the user interface that is used to design and build data imports. However, you should also know that every transform you apply within this editor is actually, quietly and behind the scenes, writing an M query for you. The letter M here is a reference to the language’s data mash-up capabilities.

For simple solutions, it is unlikely that you will ever need to even look at the M query that is being written, but there are some more complex cases where it’s helpful to understand how to read and write your own M. For the purposes of this book, covering just the Power BI essentials, you will learn how to find the M query editor within your solution and then understand how to read what it is doing for you.

For the purposes of this example, you can open up any previously built example; however, the screenshot used here is from the very first example in this chapter on basic transforms:

  1. Using any Power BI solution...

Summary

In this chapter, you learned that the Power Query Editor is an extremely powerful tool for applying business rules to incoming data. Implementing data cleansing techniques can be as simple as right-clicking on a column, or more complex, such as when building a conditional column. While the Power Query Editor does have a vast library of transforms available, you also learned that you can tap into the capabilities of R to extend what’s possible when designing queries. Finally, this chapter discussed the AI capabilities within the Power Query Editor that allow you to leverage several algorithms available within Azure Cognitive Services. In the next chapter on building the data model, you will learn about proper techniques for developing a well-designed Power BI data model to ensure your solutions can solve all your reporting needs.

Join our community on Discord

Join our community’s Discord space for discussions with the authors and other readers:

...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Microsoft Power BI Quick Start Guide - Third Edition
Published in: Nov 2022Publisher: PacktISBN-13: 9781804613498
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Authors (4)

author image
Devin Knight

Devin Knight a Microsoft Data Platform MVP and the President at Pragmatic Works Training. At Pragmatic Works, Devin determines which courses are created, delivered, and updated for customers, including 15+ Power BI courses. This is the tenth SQL Server and Business Intelligence book that he has authored. Devin often speaks at conferences such as PASS Summit, PASS Business Analytics Conference, SQL Saturdays, and Code Camps. He is also a contributing member to several PASS Virtual Chapters. Making his home in Jacksonville, FL, Devin is a contributor at the local Power BI User Group.
Read more about Devin Knight

author image
Erin Ostrowsky

Erin Ostrowsky is a creative and passionate lifelong learner. She began her career as a business journalist and researcher and found herself drawn to the power of beautifully visualized data analysis. After living overseas, Erin returned to the USA looking to marry her communication background with a technical focus and found a life changing opportunity to work as a trainer for Pragmatic Works where she focused on creating new educational materials and delivering Power BI training around the country. Erin focuses on the Power Platform tools and loves working on teams to build business intelligence solutions that businesses use and enjoy.
Read more about Erin Ostrowsky

author image
Mitchell Pearson

Mitchell Pearson has worked as a Data Platform Consultant and Trainer for the last 8 years. Mitchell has authored books on SQL Server, Power BI and the Power Platform. Data Platform experience includes designing and implementing enterprise level Business Intelligence solutions with the Microsoft SQL Server stack (T-SQL, SSIS, SSAS, SSRS), the Power Platform and Microsoft Azure. Mitchell is very active in the community: Running the local Power BI User Group, presenting at user groups locally and virtually, and creating YouTube videos for MitchellSQL
Read more about Mitchell Pearson

author image
Bradley Schacht

Bradley Schacht is a principal program manager on the Microsoft Fabric product team based in Saint Augustine, Florida. Bradley is a former consultant and trainer and has co-authored five books on SQL Server and Power BI. As a member of the Microsoft Fabric product team, Bradley works directly with customers to solve some of their most complex data problems and helps shape the future of Microsoft Fabric. Bradley gives back to the community by speaking at events, such as the PASS Summit, SQL Saturday, Code Camp, and user groups across the country, including locally at the Jacksonville SQL Server User Group (JSSUG). He is a contributor on SQLServerCentral and blogs on his personal site, BradleySchacht.
Read more about Bradley Schacht