Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Microsoft Power BI Cookbook
Microsoft Power BI Cookbook

Microsoft Power BI Cookbook: Convert raw data into business insights with updated techniques, use cases, and best practices , Third Edition

eBook
$9.99 $43.99
Paperback
$59.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

Microsoft Power BI Cookbook

Accessing, Retrieving, and Transforming Data

Power BI Desktop and dataflows in the Power BI service contain a rich set of connectors and transformation capabilities that support the integration and enhancement of data from many different sources. These features are all driven by a powerful functional language and query engine, M, which leverages source system resources when possible and can greatly extend the scope and robustness of the data retrieval process beyond what’s possible via the standard query editor interface alone. As with almost all BI projects, the design and development of the data access and retrieval process have significant implications for the analytical value, scalability, and sustainability of the overall Power BI solution.

In this chapter, we dive into both Power BI Desktop’s Get Data experience and the equivalent process with dataflows in the Power BI service in establishing and managing data source connections and queries. Although these...

Technical Requirements

The following are required to complete the recipes in this chapter:

  • Power BI Desktop.
  • SQL Server 2022 or newer with the AdventureWorksDW2022 database installed. See the Installing SQL Server and the AdventureWorks Database and Installing and Configuring Power BI Desktop sections in Chapter 1, Installing and Licensing Power BI Tools.

Importing Data

The output of Power Query (M) queries can either be loaded (imported) as compressed in-memory local tables or can merely define source tables for a data source to use via a DirectQuery connection. The import storage mode is the default and preferred option for most scenarios, as this delivers the best possible performance while also providing greater modeling flexibility, with more DAX functions supported and easier integration of distinct sources. Import is the default storage mode for Power BI Desktop. The collection of imported tables and DirectQuery tables is referred to as a semantic model.

Import semantic models created in Power BI Desktop use the same in-memory, columnar-compressed storage engine (VertiPaq) featured in Analysis Services’ Tabular import models. Import mode models support the integration of disparate data sources (for example, SQL Server and DB2) and allow more flexibility in developing metrics and row-level security roles, via...

Using DirectQuery

One of the most valuable features of Power BI is its deep support for real-time and streaming semantic models, with the ability to provide immediate visibility to business processes and events as this data is created or updated. As Power BI has become Microsoft’s flagship semantic modeling tool, with exclusive features not available in Azure Analysis Services or SQL Server Analysis Services, it has become feasible to design both DirectQuery models and composite models which utilize a mixture of DirectQuery and import storage modes on a per table basis.

The three most common candidates for DirectQuery or composite model projects are as follows:

  • The data model would consume an exorbitant amount of memory if all tables were fully loaded into memory. Even if the memory size is technically supported by large Power BI Premium capacity nodes, this would be a very inefficient and expensive use of company resources, as most BI queries only access aggregated...

Creating Dataflows

Power BI dataflows are a feature within the Microsoft Power BI service that allows users to transform and combine data from various sources, perform data transformation and cleansing operations, and then store the results in inexpensive Azure Blob Gen2 Storage.

Dataflows also use the Power Query M language and are constructed using a web-based version of Power Query Editor. In effect, dataflows are cloud-based versions of queries that you would otherwise create in Power BI Desktop.

Getting ready

To prepare for this recipe, you will need a Power BI Pro license or trial license. See the Thinking about Licensing recipe from Chapter 1, Installing and Licensing Power BI Tools. Create a new workspace in the Power BI service. This workspace should be a Pro workspace and not a Fabric or Fabric trial workspace. Fabric workspaces include the Dataflows Gen2 capabilities, which are constructed almost identically to dataflows.

In addition, you should complete...

Applying Filters

The application of precise and often complex filter conditions has always been at the heart of business intelligence, and Power BI Desktop supports rich filtering capabilities across its query, data model, and visualization components. In many scenarios, filtering at the query level via Power Query Editor and M functions is the optimal choice, as this reduces the workload of both Import and DirectQuery data models and eliminates the need to re-apply the same filter logic across multiple reports or visualizations.

Although Power Query Editor’s graphical interface can be used to configure filtering conditions, this recipe demonstrates M’s core filtering functions and the use of M in common multi-condition filter scenarios. The M expression queries constructed in this recipe are intended to highlight some of the most common filtering use cases.

Note that applying data transformations as part of a data warehouse ETL or ELT (extract-load-transform...

Transforming and Cleansing Data

The transformations applied within Power BI’s M queries serve to protect the integrity of the data model and to support enhanced analysis and visualization. The specific transformations vary based on data quality, integration needs, and the goals of the overall solution. At a minimum, developers should seek to protect the integrity of the model’s relationships and simplify the user experience via denormalization and standardization. Additionally, developers should converse with the owners of data sources to determine if required transformations can be implemented in the source or made available via SQL view objects.

This recipe demonstrates how to protect a model from duplicate values within the source data that can prevent the formation of proper relationships within the data model, which may even result in query failures. While a simple scenario is used, this recipe demonstrates scenarios you may run into while attempting to merge...

Creating Custom Columns

Business users often extend the outputs of existing reports and data models with additional columns to help them analyze and present data. The logic of these columns is generally implemented through Excel formulas or as calculated DAX columns. A superior solution, particularly if the logic cannot be migrated to a data warehouse or IT resource, is to create the columns via Power Query Editor and the M language.

Developing custom columns can also significantly enhance the ease of use and analytical power of data models and the visualizations they support. In this recipe, columns are created to apply a custom naming format and simplify the analysis of a customer dimension via existing columns.

Getting ready

To get ready for this recipe, import the DimCustomer table from the AdventureWorksDW2022 database by doing the following:

  1. Open Power BI Desktop and choose Transform data from the ribbon of the Home tab to open Power Query Editor.
  2. ...

Combining and Merging Queries

The full power of Power BI’s querying capabilities is in the integration of distinct queries representing different data sources, via its merge and append transformations. Retrieval processes that consolidate files from multiple network locations or integrate data from multiple data sources can be developed efficiently and securely. Additionally, the same join types and data transformation patterns that SQL and ETL developers are familiar with can be achieved with the M language. This recipe provides examples of combining sources into a single query and leveraging the table join functions of M to support common transformation scenarios.

Getting ready

To follow along with this recipe, you can use the Merge Queries and Append Queries icons on the Home tab of Power Query Editor to generate the join expressions used in this recipe. However, as joining queries is fundamental to the retrieval process, it is recommended to learn how to use the...

Profiling Source Data

Well before any semantic models and reports are developed, and especially before business stakeholders begin consuming the content to derive insights, it’s a good practice to assess and validate the quality of the source data. Data quality profiling exercises can reveal the presence of various issues, ranging from null or blank values in certain columns to duplicate rows, to the lack of unique or identifying (primary key) columns. The findings from this exercise inform decisions on whether the source system data itself can be cleansed or whether the BI solution will address these issues, via the various Power Query (M) data cleansing functions available.

The topic of data quality deals with the overall utility of semantic models, as well as the ability to easily process and use the data for certain purposes, including analytics and reporting. Data quality is an essential component of data governance, ensuring that business data is accurate, complete...

Diagnosing Queries

The Power Query M engine is an extremely powerful and fast data transformation and data preparation engine used across an array of products, including:

  • Excel for Windows
  • Excel for Mac
  • Power BI
  • Power Apps
  • Power Automate
  • ADF
  • SSIS
  • SQL Server Analysis Services
  • Dynamics 365 Customer Insights

While both fast and powerful, there are times when you may find that a particular query is not as performant as desired. In these instances, Query Diagnostics can help you pinpoint problematic expressions and better understand what Power Query is doing in order to identify areas for query optimization. This recipe demonstrates how a user can use Query Diagnostics to troubleshoot a query and identify how the query might be optimized to be more performant.

Getting ready

To get ready, import the FactCurrencyRate table from the AdventureWorksDW2022 database by doing the following:

  1. Open Power BI Desktop...

Extending the Core M Library

The core M library comes with hundreds of different functions to aid in data connectivity, data cleansing, and data transformation. However, one of the strengths of the M language is its ability to be easily extended with custom functions.

In this recipe, we add a simple custom function as an extension of the core M library of functions.

Getting ready

To prepare for this recipe, we first need to identify and/or create a Custom Connections folder for Power BI Desktop. Look in your Documents directory for the current user. If the folder Microsoft Power BI Desktop does not exist, create it. Navigate to the Microsoft Power BI Desktop folder, and if the folder Custom Connectors does not exist, create it.

How to extend the core M library

To implement this recipe, follow these steps:

  1. Create the following text file and save the file as Cookbook3.pq in the [Documents]\Microsoft Power BI Desktop\Custom Connectors folder.
    /...

Summary

The ability to ingest and access data is crucial to every BI project. In Power BI, this data ingest and access is driven by a powerful functional language and query engine, M. The Power Query M language provides a robust, scalable, and flexible engine for data retrieval, cleansing, and transformation.

In this chapter, we dove into Power BI Desktop’s data transformation experience and walked through the process of establishing and managing data source connections and queries. We explored both import and DirectQuery storage modes, as well as creating reuseable queries within the Power BI Service called dataflows. We then demonstrated powerful data transformation techniques, including filtering and cleansing data, creating custom columns, and combining and merging multiple queries. Finally, we demonstrated how to profile data, diagnose non-performant queries, and how to extend the core M library of functions.

In the next chapter, we leverage the knowledge gleaned...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Dive into Microsoft Data Fabric for deeper insights and robust data strategies
  • Implement Hybrid tables, create comprehensive scorecards, and establish shared cloud connections effortlessly
  • Uncover new and updated data visualization tools that turn complex data into clear, actionable charts and reports
  • Purchase of the print or Kindle book includes a free eBook in PDF format

Description

Since its first edition the Power BI Cookbook has been a best-selling resource for BI developers and data analysts to produce impactful, quality BI solutions. This new and updated edition retains the rigorous details and concepts readers of prior editions have enjoyed while also demonstrating powerful new capabilities and updated guidance aligned to the current state of the platform. In this book, with step-by-step instructions, you will learn to navigate the complexities of data integration and visualization in Power BI. From creating robust data models to implementing sophisticated reporting techniques, this Power BI book empowers you to make informed decisions based on actionable insights. It also introduces you to new capabilities such as Hybrid tables and scorecards, enhancing your ability to communicate and analyze business performance. It also expands and improvises on the core of the previous edition like parameterizing Power BI solutions, authoring reports, data intelligence, and integrating advanced analytics. This edition not only updates you on the latest features but also prepares you for future innovations with a preview of upcoming AI enhancements in Power BI. Whether you're refining your skills or aspiring to become an expert, this book is an invaluable resource for leveraging Power BI to its fullest potential

Who is this book for?

This book is designed for data analysts, business intelligence professionals, and anyone involved in data processing or analytics who seeks to enhance their skills with Power BI’s latest features and prepare for future advancements in the field

What you will learn

  • Analyze and integrate business data using Microsoft Data Fabric
  • Create impactful visualizations and manage Hybrid tables
  • Develop shared cloud connections and advanced scorecards
  • Enhance report accuracy and dynamics using real-time data processing
  • Implement efficient data governance and security measures within Power BI

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jul 31, 2024
Length: 598 pages
Edition : 3rd
Language : English
ISBN-13 : 9781835464663
Category :
Languages :
Concepts :
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 : Jul 31, 2024
Length: 598 pages
Edition : 3rd
Language : English
ISBN-13 : 9781835464663
Category :
Languages :
Concepts :
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
Microsoft Power BI Cookbook
$59.99
Extending Power BI with Python and R
$54.99
Microsoft Power BI Performance Best Practices
$44.99
Total $ 159.97 Stars icon
Banner background image

Table of Contents

15 Chapters
Installing and Licensing Power BI Tools Chevron down icon Chevron up icon
Accessing, Retrieving, and Transforming Data Chevron down icon Chevron up icon
Building a Power BI Semantic Model Chevron down icon Chevron up icon
Authoring Power BI Reports Chevron down icon Chevron up icon
Working in the Power BI Service Chevron down icon Chevron up icon
Getting Serious About Date Intelligence Chevron down icon Chevron up icon
Parameterizing Power BI Solutions Chevron down icon Chevron up icon
Implementing Dynamic User-Based Visibility in Power BI Chevron down icon Chevron up icon
Applying Advanced Analytics and Custom Visuals Chevron down icon Chevron up icon
Enhancing and Optimizing Existing Power BI Solutions Chevron down icon Chevron up icon
Deploying and Distributing Power BI Content Chevron down icon Chevron up icon
Integrating Power BI with Other Applications Chevron down icon Chevron up icon
Working with Premium and Microsoft Fabric 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 Half star icon 4.7
(23 Ratings)
5 star 87%
4 star 8.7%
3 star 0%
2 star 0%
1 star 4.3%
Filter icon Filter
Top Reviews

Filter reviews by




P. Laws Sep 03, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I'm largely self-taught on Power BI but this is a great book to really kick off right the way - all the way through from installing the software and other supporting tools like Report Builder, building a model and report and then improving and documenting it.Each chapter is very well laid out in a clear format - I like the structure with "Getting ready", "How it works" and "There's more" in nice bitesize chunks with each chapter closing out with a good Summary.There are links to GitHub so you can do the doing which works really well.There are some great modelling techniques in this book for both the beginner and more advanced user.Definitely another great addition to the bookshelf with nice colour screenshots, well laid out as with other Packt books I've read and does a great job of getting the technical aspects articulated clearly.
Amazon Verified review Amazon
Devaraj Oct 02, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book covers essential aspects such as data connectivity, modeling, visualization, and advanced analytics. It delves into the Power Query (M) language for data transformation, DAX measures for business intelligence, and the importance of creating well-structured semantic models to optimize performance and reporting.Additionally, it highlights the use of real-time data processing,RLS for data access control, and integration with external applications, making it a valuable resource for enhancing Power BI knowledge and skills.Key InsightsUnderstanding DAX and M languages is crucial for advanced data transformation and analysis in Fabric.Semantic models should be well-structured to ensure optimal performance and support diverse reporting needs.Real-time data capabilities in Power BI enhance decision-making processes and provide timely insights.Implementing RLS ensures that users access only relevant data, enhancing data security and compliance.
Amazon Verified review Amazon
Federico Pastor Sep 02, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is an excellent guide for enhancing your Power BI skills, offering a comprehensive collection of practical recipes to tackle real-world business intelligence challenges.The content is well-organized, taking you from the basics to advanced topics such as data modeling and DAX for complex data analysis. Each chapter focuses on specific functionalities or tasks, making it easy for readers to find relevant information and apply best practices.The cookbook-style instructions are straightforward and easy to follow, allowing users to apply the steps directly to their projects. The real-life examples provided illustrate how to effectively utilize Power BI features to simplify and improve your work.With the latest edition incorporating all new features and enhancements, this book provides valuable tips on how to excel at analysing any type of data using Power BI visuals and functions. Highly recommended for anyone looking to deepen their understanding of Power BI.And guess what? It’s in colour! So you won’t just learn a lot—you’ll have a colourful time doing it. 🌈
Amazon Verified review Amazon
James W Sep 01, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Wow this book is great and full colour too, every page I flick to I see something interesting to dig into full of great inspiration and insightful tips
Amazon Verified review Amazon
Thomas Rice Sep 25, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I'll be clear and brief: this is a great Power BI cookbook! I've read a handful of Power BI books over the years and I think this is one of the best ones to date. It covers everything from licensing to getting started with Microsoft fabric. With more than 550 pages across 13 chapters, you will walk away with a deep understanding of Power BI best practices. Easy to read, follow, and understand too!
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.