Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Microsoft Power BI Cookbook
Microsoft Power BI Cookbook

Microsoft Power BI Cookbook: Creating Business Intelligence Solutions of Analytical Data Models, Reports, and Dashboards

eBook
AU$50.99 AU$72.99
Paperback
AU$90.99
Subscription
Free Trial
Renews at AU$24.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
Table of content icon View table of contents Preview book icon Preview Book

Microsoft Power BI Cookbook

Accessing and Retrieving Data

In this chapter, we will cover the following recipes:

  • Viewing and analyzing M functions in the Query Editor
  • Establishing and managing connections to data sources
  • Building source queries for DirectQuery models
  • Importing data to Power BI Desktop models
  • Applying multiple filtering conditions
  • Choosing columns and column names
  • Transforming and cleansing source data
  • Creating custom and conditional columns
  • Integrating multiple queries
  • Choosing column data types
  • Visualizing the M library

Introduction

Power BI Desktop contains a very rich set of data source connectors and transformation capabilities that support the integration and enhancement of source data. 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 has great implications for the analytical value, scalability, and sustainability of the overall Power BI solution.

In this chapter, we dive into Power BI Desktop's Get Data experience and walk through the process of establishing and managing data source connections and queries. Examples are provided of using the Query...

Viewing and analyzing M functions

Every time you click on a button to connect to any of Power BI Desktop's supported data sources or apply any transformation to a data source object, such as changing a column's data type, one or multiple M expressions are created reflecting your choices. These M expressions are automatically written to dedicated M documents and, if saved, are stored within the Power BI Desktop file as Queries. M is a functional programming language like F#, and it's important that Power BI developers become familiar with analyzing and later writing and enhancing the M code that supports their queries.

Getting ready

  1. Build a query through the user interface that connects to the AdventureWorksDW2016CTP3...

Establishing and managing connections to data sources

There are two primary components of queries in Power BI: the data source and the query logic executed against this source. The data source includes the connection method (DirectQuery or Import), its privacy setting, and the authentication credentials. The query logic consists of the M expressions represented as queries in the Query Editor and stored internally as M documents.

In a typical corporate BI tool, such as SQL Server Reporting Services (SSRS), the properties of a data source such as the server and database name are defined separately from the queries that reference them. In Power BI Desktop, however, by default each individual query created explicitly references a given data source (for example, server A and database B). This creates an onerous, manual process of revising each query if necessary to change the source...

Building source queries for DirectQuery models

One of the most valuable features of Power BI is its deep support for real-time and streaming datasets--the ability to provide immediate visibility to business processes and events as this data is created or updated. As Power BI Desktop's data modeling engine reflects the latest SQL Server Analysis Services (SSAS) features, including the enhanced DirectQuery mode for SSAS 2016, it becomes feasible to design DirectQuery models in Power BI Desktop and thus avoid the scalability limitations and scheduled refresh requirements of import-based models.

This recipe walks through the primary steps in designing the data access layer that supports a DirectQuery model in Power BI Desktop. As these models are not cached into memory and dynamically convert the DAX queries from report visualizations to SQL statements, guidance is provided to...

Importing data to Power BI Desktop models

Import is the default data connectivity mode for Power BI Desktop, and the import models created in Power BI Desktop use the same in-memory, columnar compressed storage engine (Vertipaq) featured in SSAS Tabular 2016+ 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 given via full support for all DAX functions.

This recipe describes a process of using M and the Query Editor to develop the queries supporting a standard star-schema analytical model. A staging query approach is introduced as a means of efficiently enhancing the dimensions of a model, and tips are included to use less resources during refresh and to avoid refresh failures from revised source data. More details of these methods are...

Applying multiple filtering conditions

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 the 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 for re-applying the same filter logic across multiple reports.

Although the Query Editor 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.

Getting ready

...

Choosing columns and column names

The columns selected in data retrieval queries impact the performance and scalability of both import and DirectQuery data models. For import models, the resources required by the refresh process and the size of the compressed data model are directly impacted by column selection. Specifically, the cardinality of columns drives their individual memory footprint and memory (per column) correlates closely to query duration when these columns are referenced in measures and report visuals. For DirectQuery models, the performance of report queries is directly affected.

Regardless of the model type, how this selection is implemented also impacts the robustness of the retrieval process. Additionally, the names assigned to columns (or accepted from the source) directly impact the Q & A or natural language query experience. This recipe provides examples...

Transforming and cleansing source 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 to implement varies based on data quality, integration needs, and the goals of the overall solution. However, at a minimum, developers should look to protect the integrity of the model's relationships and to simplify the user experience via denormalization and standardization.

This recipe includes examples of protecting a data model from duplicate values and enhancing the quality of a dimension column via a relationship to a separate data source.

Getting ready

To best follow the duplicate removal...

Creating custom and conditional 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 quickly be migrated to a data warehouse or IT resource, is to create the columns via the Query Editor and 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 the examples of this recipe, columns are created to simplify the analysis of a customer dimension via existing columns and to apply a custom naming format.

How to do it...

...

Integrating multiple queries

The full power of Power BI's querying capabilities is in the integration of multiple queries via it's merge and append operations. Retrieval processes which consolidate files from multiple network locations or which integrate data from multiple data sources can be developed efficiently and securely. Additionally, the same join types and data transformation patterns 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...

Choosing column data types

Setting the data types of columns in Power BI Desktop is usually the final step of queries and has great implications for all layers of the solution including data refresh, modeling, and visualization. Choosing appropriate data types reduces the risk of refresh failures, ensures consistent report results, and provides analytical flexibility to the data model and visualization layers.

This recipe includes four common examples of choosing and defining data types to load to Power BI Desktop. Additional details on data types and the implications of data types for Power BI development are contained in the sections following these examples.

How to do it...

...

Visualizing the M library

To implement complex and less common data transformation requirements, it's often necessary to browse the M library to find a specific function or review the parameters of a specific function. This short recipe provides a pre-built M query expression you can use to retrieve the M library into a table for analysis in Power BI Desktop. Additionally, an example is provided of visualizing and cross-filtering this table of functions on the Power BI report canvas.

How to do it...

  1. Open a new Power BI Desktop file (PBIX) and create a blank Query.
  2. Enter the following M code in the Advanced Editor:
Figure 157: M Expression to Retrieve a Table of the M Library
  • The Query Editor should look like the following...
Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • From connecting to your data sources to developing and deploying immersive, mobile-ready dashboards and visualizations, this book covers it all
  • Over 90 hands-on, technical recipes, tips, and use cases from across the Power BI platform including the Power BI Service and Mobile Applications
  • Proven development techniques and guidance for implementing custom solutions with DAX and M languages

Description

Microsoft Power BI is a business intelligence and analytics platform consisting of applications and services designed to provide coherent, visual and interactive insights of data. This book will provide thorough, technical examples of using all primary Power BI tools and features as well as demonstrate high impact end-to-end solutions that leverage and integrate these technologies and services. Get familiar with Power BI development tools and services, go deep into the data connectivity and transformation, modeling, visualization and analytical capabilities of Power BI, and see Power BI’s functional programming languages of DAX and M come alive to deliver powerful solutions to address common, challenging scenarios in business intelligence. This book will excite and empower you to get more out of Power BI via detailed recipes, advanced design and development tips, and guidance on enhancing existing Power BI projects.

Who is this book for?

This book is for BI professionals who wish to enhance their knowledge of Power BI beyond and to enhance the value of the Power BI solutions they deliver to business users. Those who are looking at quick solutions to common problems while using Power BI will also find this book to be a very useful resource .Some experience with Power BI will be useful.

What you will learn

  • Cleanse, stage, and integrate your data sources with Power BI
  • Abstract data complexities and provide users with intuitive, self-service BI capabilities
  • Build business logic and analysis into your solutions via the DAX programming language and dynamic, dashboard-ready calculations
  • Take advantage of the analytics and predictive capabilities of Power BI
  • Make your solutions more dynamic and user specific and/or defined including use cases of parameters, functions, and row level security
  • Understand the differences and implications of DirectQuery, Live Connections, and Import-Mode Power BI datasets and how to deploy content to the Power BI Service and schedule refreshes
  • Integrate other Microsoft data tools such as Excel and SQL Server Reporting Services into your Power BI solution

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 27, 2017
Length: 802 pages
Edition : 1st
Language : English
ISBN-13 : 9781788293785
Vendor :
Microsoft
Category :
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 Details

Publication date : Sep 27, 2017
Length: 802 pages
Edition : 1st
Language : English
ISBN-13 : 9781788293785
Vendor :
Microsoft
Category :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
AU$24.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
AU$249.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 AU$5 each
Feature tick icon Exclusive print discounts
AU$349.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 AU$5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total AU$ 242.97
Microsoft Power BI Cookbook
AU$90.99
Microsoft Power BI Quick Start Guide
AU$68.99
Mastering Microsoft Power BI
AU$82.99
Total AU$ 242.97 Stars icon

Table of Contents

13 Chapters
Configuring Power BI Development Tools Chevron down icon Chevron up icon
Accessing and Retrieving Data Chevron down icon Chevron up icon
Building a Power BI Data Model Chevron down icon Chevron up icon
Authoring Power BI Reports Chevron down icon Chevron up icon
Creating Power BI Dashboards Chevron down icon Chevron up icon
Getting Serious with 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
Developing Solutions for System Monitoring and Administration 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

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.7
(25 Ratings)
5 star 56%
4 star 8%
3 star 4%
2 star 12%
1 star 20%
Filter icon Filter
Top Reviews

Filter reviews by




M. Riedmueller Nov 30, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Der Autor beschreibt nicht nur, was man beim Entwickeln von Lösungen mit Power BI tun muss, sondern erläutert auch die Hintergründe. Insbesondere veranlasst er den Leser, sich vor einer Aktivität darüber Gedanken zu machen, was man erreichen will und wie das in die allgemeinen Rahmenbedingungen passt.Was evtl. ein wenig fehlt sind Kapitel für Einsteiger. Da das Buch aber schon jetzt sehr umfangreich ist, kann man sich das auch im Netz beschaffen.
Amazon Verified review Amazon
Jennifer Hutter Dec 04, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I had no idea that Power BI could support these kinds of custom solutions!! Unbelievable!
Amazon Verified review Amazon
Sweet james jones Dec 04, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A terrific resource for Power BI users. Explanations are very thorough and easy to follow in the context of BI and particularly SSAS.
Amazon Verified review Amazon
NotForHire Jan 29, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is the best book I have yet seen for those who already have some experience with Power BI in an enterprise setting, and seek to enhance their skills. The author uses his recipes to teach fundamental principles as well as Power BI features. The recipes in the book are well-chosen and immediately useful to the busy practitioner. Highest recommendation and congratulations to the author for his outstanding work.
Amazon Verified review Amazon
maridee oday Nov 27, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Simply put, this is a wonderful book. I am an intermediate Power BI user, and I am basically reading it cover to cover because I don't want to miss a detail. I have found so many delightful gems within the pages. The author not only presents tactics for utilizing Power BI, but also strategy for overall product usage that will benefit my clients tremendously in the simplicity, efficiency, elegance, and relevancy of the reports and solutions that I am enabled to create. A huge thank you to the author for this great resource!
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.