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
£27.98 £39.99
Paperback
£49.99
Subscription
Free Trial
Renews at £16.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. £16.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
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 : 9781788290142
Vendor :
Microsoft
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. £16.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

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

Packt Subscriptions

See our plans and pricing
Modal Close icon
£16.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
£169.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
£234.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 £ 132.97
Microsoft Power BI Cookbook
£49.99
Microsoft Power BI Quick Start Guide
£37.99
Mastering Microsoft Power BI
£44.99
Total £ 132.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

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.