Microsoft Power BI Cookbook
By Brett Powell
()
About this ebook
Get more out of Microsoft Power BI turning your data into actionable insights
About This Book- 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
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
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.
Style and approachThis book consists of practical recipes on Power BI that target novices as well as intermediate Power BI users. It goes deep into the technical issues, covers additional protocols, and many more real-live examples.
Read more from Brett Powell
Microsoft Power BI Cookbook: Convert raw data into business insights with updated techniques, use cases, and best practices Rating: 0 out of 5 stars0 ratingsMicrosoft Power BI Cookbook: Gain expertise in Power BI with over 90 hands-on recipes, tips, and use cases Rating: 0 out of 5 stars0 ratingsMastering Microsoft Power BI: Expert techniques for effective data analytics and business intelligence Rating: 0 out of 5 stars0 ratings
Related to Microsoft Power BI Cookbook
Related ebooks
Power BI for Jobseekers: Learn how to create interactive dashboards and reports, and gain insights from the data (English Edition) Rating: 0 out of 5 stars0 ratingsPower BI Data Modeling: Build Interactive Visualizations, Learn DAX, Power Query, and Develop BI Models Rating: 0 out of 5 stars0 ratingsData Analysis and Business Modeling with Excel 2013 Rating: 1 out of 5 stars1/5Microsoft Power BI A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratingsPro Power BI Architecture: Sharing, Security, and Deployment Options for Microsoft Power BI Solutions Rating: 0 out of 5 stars0 ratingsSelf-Service AI with Power BI Desktop: Machine Learning Insights for Business Rating: 0 out of 5 stars0 ratingsInstant Creating Data Models with PowerPivot How-to Rating: 1 out of 5 stars1/5Self-Service Data & Analytics Third Edition Rating: 0 out of 5 stars0 ratingsMastering Business Intelligence: From Data to Decisions: Course, #1 Rating: 0 out of 5 stars0 ratingsAzure Data Factory Cookbook: A data engineer's guide to building and managing ETL and ELT pipelines with data integration Rating: 0 out of 5 stars0 ratingsTeach Yourself VISUALLY Power BI Rating: 0 out of 5 stars0 ratingsPower BI Pro Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratingsPower BI DAX Essentials Getting Started with Basic DAX Functions in Power BI Rating: 5 out of 5 stars5/5Demand Forecasting A Complete Guide - 2021 Edition Rating: 0 out of 5 stars0 ratingsTableau 10 Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratingsDAX Cookbook: Over 120 recipes to enhance your business with analytics, reporting, and business intelligence Rating: 0 out of 5 stars0 ratingsPower Query for Power BI and Excel Rating: 0 out of 5 stars0 ratingsLearning Tableau 2019 - Third Edition: Tools for Business Intelligence, data prep, and visual analytics, 3rd Edition Rating: 0 out of 5 stars0 ratingsBig Data Visualization Rating: 0 out of 5 stars0 ratingsBusiness analytics A Complete Guide - 2019 Edition Rating: 0 out of 5 stars0 ratingsSupercharge Power BI: Power BI is Better When You Learn To Write DAX Rating: 5 out of 5 stars5/5Hands-On Microsoft Lists: Create custom data models and improve the way data is organized using Lists in Microsoft 365 Rating: 0 out of 5 stars0 ratingsExpert T-SQL Window Functions in SQL Server 2019: The Hidden Secret to Fast Analytic and Reporting Queries Rating: 0 out of 5 stars0 ratingsSAP Manufacturing A Complete Guide - 2021 Edition Rating: 0 out of 5 stars0 ratingsPower BI for the Excel Analyst: Your Essential Guide to Power BI Rating: 0 out of 5 stars0 ratingsMicrosoft Dynamics AX 2009 Administration Rating: 0 out of 5 stars0 ratings
Data Visualization For You
How to Become a Data Analyst: My Low-Cost, No Code Roadmap for Breaking into Tech Rating: 0 out of 5 stars0 ratingsTeach Yourself VISUALLY Power BI Rating: 0 out of 5 stars0 ratingsHow to Lie with Maps Rating: 4 out of 5 stars4/5Data Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5Data Visualization: A Practical Introduction Rating: 5 out of 5 stars5/5Effective Data Storytelling: How to Drive Change with Data, Narrative and Visuals Rating: 4 out of 5 stars4/5DAX Patterns: Second Edition Rating: 5 out of 5 stars5/5Fieldwork Handbook: A Practical Guide on the Go Rating: 0 out of 5 stars0 ratingsLearning PySpark Rating: 0 out of 5 stars0 ratingsLearning pandas - Second Edition Rating: 4 out of 5 stars4/5Google Analytics 4 Migration Quick Guide 2022: Universal Analytics disappears in July 2023 - are you ready? Rating: 0 out of 5 stars0 ratingsSpatial Statistics Illustrated Rating: 5 out of 5 stars5/5Data Analytics & Visualization All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsData Analysis with Stata Rating: 5 out of 5 stars5/5Functional Aesthetics for Data Visualization Rating: 0 out of 5 stars0 ratingsTableau 10 Business Intelligence Cookbook Rating: 0 out of 5 stars0 ratingsVisual Analytics with Tableau Rating: 0 out of 5 stars0 ratingsVisualizing Graph Data Rating: 0 out of 5 stars0 ratingsMastering D3.js Rating: 3 out of 5 stars3/5Data Visualization with Excel Dashboards and Reports Rating: 4 out of 5 stars4/5Top 20 Essential Skills for ArcGIS Pro Rating: 0 out of 5 stars0 ratingsNo-Code Data Science: Mastering Advanced Analytics, Machine Learning, and Artificial Intelligence Rating: 5 out of 5 stars5/5
Reviews for Microsoft Power BI Cookbook
0 ratings0 reviews
Book preview
Microsoft Power BI Cookbook - Brett Powell
Microsoft Power BI Cookbook
Creating Business Intelligence Solutions of Analytical Data Models, Reports, and Dashboards
Brett Powell
BIRMINGHAM - MUMBAI
Microsoft Power BI Cookbook
Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: September 2017
Production reference: 1220917
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78829-014-2
www.packtpub.com
Credits
Foreword
Microsoft Power BI Cookbook is a great example of how to leverage the multitude of features that are available in Power BI. You will find some great examples in this book that will first explain the issues and then give a solution on how to achieve the desired result. I, personally, learned something when going through this cookbook and all the recipes provided in it. This is a book that can be picked up and referenced when looking for solutions for particular challenges or issues. Likewise, it is a great read from cover to cover to expand your skills, which in turn will help build great Power BI Models for your clients/customers.
Gilbert Quevauvilliers,
Microsoft MVP - Power BI & Microsoft Power BI Consultant at Fourmoo
About the Author
Brett Powell is the owner of and business intelligence consultant at Frontline Analytics LLC, a data and analytics research and consulting firm and Microsoft Power BI partner. He has worked with Power BI technologies since they were first introduced as the SQL Server 2008R2 PowerPivot add-in for Excel 2010. He has contributed to the design and development of Microsoft and Power BI solutions of diverse scale and complexity across the retail, manufacturing, financial, and services industries. Brett regularly blogs and shares technical papers regarding the latest MSBI and Power BI features and development techniques and patterns at Insight Quest. He is also an organizer of the Boston BI User Group.
Erin Stellato, featured in Developing Solutions for System Monitoring and Administration, is a principal consultant at SQLskills and Microsoft Data Platform MVP.
I'd first like to thank Varsha Shetty, acquisition editor at Packt, for giving me the opportunity to author this book and her guidance throughout the planning process. I'd also like to thank the Packt board and team for approving the book outline and for their flexibility with page counts and topics. Like most Power BI projects, we followed an agile delivery model in creating this book and this allowed us to include essential details supporting the recipes and the latest Power BI features. Additionally, I'd like to thank Mayur Pawanikar, content editor at Packt, for his thorough reviews and guidance throughout the development process. His contributions were invaluable to the structure and overall quality of the book.
I'd also like to thank Gilbert Quevauvilliers and Juan Tomas Oliva Ramos for their technical reviews and suggestions.
Finally, I'd like to thank the Power BI team for creating such an amazing platform and for everyone around the Power BI community that contributes documentation, white papers, presentations, videos, blogs, and more.
About the Reviewers
Gilbert Quevauvilliers has been working in the BI space for the past 9 years. He started out learning the basics of business intelligence on the Microsoft stack, and as time went on, he became more experienced. Gilbert has since moved into the Power BI space, after starting out with Power Pivot in Excel 2010. He has used Power BI since its inception and works exclusively in it. He has been recognized with the Microsoft MVP award for his contributions to the community and helping other users.
Gilbert is currently consulting in his own company, called FourMoo (which represents the four family members). Fourmoo provides Microsoft Power BI solutions for business challenges by using customers' data and working with their business users. Gilbert also has an active blog at http://www.fourmoo.com/blog/. This is the first book that he has been asked to review.
I would like to say a big thanks to my wife, Sian, for her endless support and for helping me find the time to review this book.
Ruben Oliva Ramos is a computer systems engineer from Tecnologico de Leon Institute, with a master's degree in computer and electronic systems engineering, teleinformatics, and networking specialization from the University of Salle Bajio in Leon, Guanajuato, Mexico. He has more than 5 years of experience in developing web applications to control and monitor devices connected with Arduino and Raspberry Pi using web frameworks and cloud services to build the Internet of Things applications.
He is a mechatronics teacher at the University of Salle Bajio and teaches students of the master's degree in design and engineering of mechatronics systems. Ruben also works at Centro de Bachillerato Tecnologico Industrial 225 in Leon, Guanajuato, Mexico, teaching subjects such as electronics, robotics and control, automation, and microcontrollers at Mechatronics Technician Career; he is a consultant and developer for projects in areas such as monitoring systems and datalogger data using technologies (such as Android, iOS, Windows Phone, HTML5, PHP, CSS, Ajax, JavaScript, Angular, and ASP.NET), databases (such as SQlite, MongoDB, and MySQL), web servers (such as Node.js and IIS), hardware programming (such as Arduino, Raspberry pi, Ethernet Shield, GPS, and GSM/GPRS, ESP8266), and control and monitor systems for data acquisition and programming.
He wrote Internet of Things Programming with JavaScript by Packt Publishing. He is also involved in the monitoring, controlling, and acquisition of data with Arduino and Visual Basic .NET for Alfaomega.
I would like to thank my savior and lord, Jesus Christ, for giving me the strength and courage to pursue this project; my dearest wife, Mayte; our two lovely sons, Ruben and Dario; my dear father, Ruben; my dearest mom, Rosalia; my brother, Juan Tomas; and my sister, Rosalia, whom I love, for all their support while reviewing this book, for allowing me to pursue my dream, and tolerating not being with them after my busy day job.
Juan Tomás Oliva Ramos is an environmental engineer from the university of Guanajuato, with a master's degree in administrative engineering and quality. He has more than 5 years of experience in management and development of patents, technological innovation projects, and development of technological solutions through the statistical control of processes.
He is a teacher of statistics, entrepreneurship and technological development of projects since 2011. He became an entrepreneur mentor, and started a new department of technology management and entrepreneurship at Instituto Tecnologico Superior de Purisima del Rincon.
He is a Packt Publishing reviewer and he has worked on the book: Wearable designs for Smart watches, Smart TV's and Android mobile devices.
He has developed prototypes through programming and automation technologies for the improvement of operations, which have been registered to apply for his patent.
I want to thank God for giving me wisdom and humility to review this book.
I want to thank Packt for giving me the opportunity to review this amazing book and to collaborate with a group of committed people.
I want to thank my beautiful wife, Brenda, our two magic princesses, Regina and Renata, and our next member, Angel Tadeo, all of you, give me the strength, happiness and joy to start a new day. Thanks for being my family.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com. Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com, and as a print book customer, you are entitled to a discount on the eBook copy.
Get in touch with us at [email protected] for more details. At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review.
If you'd like to join our team of regular reviewers, you can email us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback. Help us be relentless in improving our products!
Table of Contents
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Configuring Power BI Development Tools
Introduction
Configuring Power BI Desktop options and settings
Getting ready
How to do it...
Installing and running Power BI Desktop
Configuring Power BI Desktop options
How it works...
There's more...
See also
Power BI's advantages over Excel
Power BI Security and Data Source Privacy
Installing the On-Premises Data Gateway
Getting ready
Hardware and network configuration
How to do it...
Installation of on-premises gateway
How it works...
Gateway recovery key
There's more...
See also...
Installing Power BI Publisher for Excel
How to do it...
Installation of Power BI Publisher for Excel
There's more...
Installing and Configuring DAX Studio
How to do it...
Installation of DAX Studio
Configuration of DAX Studio
How it works...
There's more...
Guy in a Cube video channel
Accessing and Retrieving Data
Introduction
Viewing and analyzing M functions
Getting ready
How to do it...
Formula Bar
Advanced Editor window
How it works...
Query folding
M query structure
Lazy evaluation
There's more...
Partial query folding
Limitations of query folding
See also...
M language references
Establishing and managing connections to data sources
Getting ready
How to do it...
Isolate data sources from individual queries
Query groups
Manage source credentials and privacy levels
How it works...
Data Source settings
Data source privacy settings
There's more...
See also
Building source queries for DirectQuery models
Getting ready
How to do it...
Applying M transformations with DirectQuery models
How it works...
There's more...
DirectQuery project candidates
DirectQuery performance
See also
Importing data to Power BI Desktop models
How to do it...
Denormalize a dimension
Provide automatic sorting
How it works...
There's more...
One GB dataset limit and Power BI Premium
See also
Applying multiple filtering conditions
Getting ready
How to do it...
Query filter example steps
How it works...
There's more...
Filtering via the Query Editor interface
See also
Choosing columns and column names
How to do it...
Identify expensive columns
Select columns
Rename columns
How it works...
Column memory usage
There's more...
Fact table column eliminations
Column orders
See also
Transforming and cleansing source data
Getting ready
How to do it...
Remove duplicates
Update a column through a join
There's more...
See also
Creating custom and conditional columns
How to do it...
Create a dynamic banding attribute
Create a formatted name column
Comparing the current and previous rows
How it works...
Conditional expression syntax
Case sensitivity
Conditional expression evaluation
Query folding of custom columns
There's more...
Add column from example
Conditional columns interface
DAX calculated columns
Error handling and comments
Integrating multiple queries
Getting ready
How to do it...
Consolidate files
Self-joining querying
How it works...
Nested join versus flat join
Append multiple files
There's more...
Combine binaries
Staging queries versus inline queries
See also
Choosing column data types
How to do it...
Remove automatic type detection steps
Align relationship column data types
Add numeric columns from text columns
Use fixed decimal number for precision
How it works...
Automatic data type detection
Numeric data types
Power BI Desktop automatic time intelligence
There's more...
Data type impacts
Date with locale
Percentage data type
See also
Visualizing the M library
How to do it...
How it works...
There's more...
Building a Power BI Data Model
Introduction
Designing a multi fact data model
Getting ready
Setting business expectations
How to do it...
Four-step dimensional design process
Data warehouse and implementation bus matrix
Choose the dataset storage mode - Import or DirectQuery
In-Memory mode
DirectQuery mode
How it works...
DAX formula and storage engine
There's more...
Project ingestion questions
Power BI delivery approaches
See also
Implementing a multi fact data model
How to do it...
SQL view layer
M queries in Power BI Desktop
Create model relationships
Author DAX measures
Configure model metadata
There's more...
Shared views
Handling one-to-many and many-to-many relationships
Getting ready
How to do it...
Single, bidirectional, and CROSSFILTER()
Single direction relationships
Bidirectional relationship
CROSSFILTER() Measure
Many-to-many relationships
Bidirectional cross-filtering for many-to-many
How it works...
Ambiguous relationships
CROSSFILTER()
There's more...
DirectQuery supported
See also
Assigning data formatting and categories
How to do it...
Data formats
Data category
How it works...
There's more...
Model level settings
See also
Configuring Default Summarization and sorting
How to do it...
Sort By Column
DAX Year-Month sorting
DAX Ranking Sort
Default Summarization
How it works...
Default Summarization
There's more...
Quick measures
See also
Setting the visibility of columns and tables
How to do it...
Isolate measures from tables
How it works...
Measure home tables
There's more...
Hiding hierarchy columns
Group visibility
Row level security visibility
Visibility features from SSAS
Embedding business definitions into DAX measures
Getting ready
How to do it...
Sales and cost metrics
Margin and count metrics
Secondary relationships
How it works...
Date relationships
There's more...
Measure definitions
Measure names and additional measures
See also
Enriching a model with analysis expressions
How to do it...
Pricing analysis
Geometric mean at all grains
How it works...
Pricing analysis
Building analytics into data models with DAX
How to do it...
Cross-selling opportunities
Accessories but not bike customers
Bike only customers
Active verus inactive customers
Actual versus budget model and measures
How it works...
Filter Context Functions
There's more...
SUMMARIZECOLUMNS()
Integrating math and statistical analysis via DAX
How to do it...
Correlation coefficient
Goodness-of-Fit test statistic
How it works...
Correlation coefficient syntax
Goodness-of-Fit logic and syntax
Supporting virtual table relationships
How to do it...
Segmentation example
Summary to detail example
Actual versus plan
How it works...
Year and month selected
Virtual relationship functions
There's more...
Multiple dimensions
Alternatives to virtual relationships
See also
Creating browsable model hierarchies and groups
How to do it...
Create hierarchy columns with DAX
Implement a hierarchy
Create and manage a group
How it works...
DAX parent and child functions
Include other grouping option
Model scoped features
There's more...
DAX calculated columns as rare exceptions
Natural hierarchies versus unnatural hierarchies
Grouping dates and numbers
DirectQuery models supported
See also
Authoring Power BI Reports
Introduction
Building rich and intuitive Power BI reports
Getting ready
Stakeholder Matrix
How to do it...
Report planning and design process
Report Design Example
European Sales and Margin Report Page
European country sales and margin report page
How it works...
European sales report design
There's more...
Power BI report design checklist
Custom visuals
Published Power BI datasets as data sources
See also
Creating table and matrix visuals
How to do it...
Table visual exceptions
Identifying blanks in tables
Matrix visual hierarchies
How it works...
Matrix visual navigation
There's more...
URL and mail to email support
Percent of total formatting
Measures on matrix rows
Data bar conditional formatting
Utilizing graphical visualization types
Getting ready
Choosing visual types
How to do it...
Waterfall chart for variance analysis
Line chart with conditional formatting
Shape map visualization
How it works...
Shape map
Enhancing exploration of reports
Getting ready
Drillthrough report page requirements
Enable Cortana integration and Q&A
How to do it...
Create featured Q&A questions
Parameterized Q&A report
Cortana integration
Drillthrough Report Pages
Report themes
How it works...
Report theme JSON files
There's more...
Conversational BI - mobile support for Q&A
See also
Integrating card visualizations
Getting ready
How to do it...
KPI visual
Multi-row card
There's more...
Gauge visualizations
Controlling interactive filtering between visuals
How to do it...
Visual interaction control
How it works...
Current year Measures
Associating slicers with report pages
How to do it...
Configure dimension slicers
Horizontal slicers
Customize a date slicer
Relative date filters
How it works...
Date slicer
There's more...
Text search
Numeric range slicers
Applying filters at different scopes
How to do it...
Report and page level filters
Visual level filter - top N
How it works...
DAX queries from report, page, and visual Filters
There's more...
Advanced report and page level filters
Formatting reports for publication
How to do it...
Visual alignment and distribution
Shapes as backgrounds and groups
There's more...
Snap objects to grid and keyboard shortcuts
Textbox with email link
Format painter
See also
Designing mobile report layouts
Getting ready
Plan for mobile consumption
How to do it...
Phone layout - Europe report page
Phone layout - United Kingdom report page
How it works...
There's more...
Slicers and drill-down on mobile devices
Mobile-optimized dashboards
See also
Creating Power BI Dashboards
Introduction
Building a Power BI dashboard
How to do it...
Dashboard design process
Dashboard development process
Constructing an enterprise dashboard
How to do it...
Dashboard design process
How it works...
Dual KPI custom visual
Supporting tiles
Developing dynamic dashboard metrics
How to do it...
Dynamic date columns
KPI target measures
How it works...
Target measure - trailing 6 months
Preparing datasets and reports for Q & A natural language queries
Getting ready
Determine use cases and feasibility
How to do it...
Prepare a model for Q & A
Model metadata
Model design
Apply synonyms
Analyze Q & a use cases
Apply synonyms
Publish the dataset
Embedding analytical context into visualizations
How to do it...
Design the visual
Create the visual
How it works...
Color saturation rule
Tooltip measures
There's more...
Exposing what matters - top N and percentage of total visualizations
How to do it...
Top 25 resellers with below -3% margin
Last year's top 50 products with below -10% growth
How it works...
Prior year rank measure
Visualizing performance relative to targets with KPIs and gauges
How to do it...
Create the visuals
Grouping KPIs
Publish KPIs to dashboard
How it works...
Current month filter
Time intelligence measures
Leveraging Power BI reports in Power BI dashboards
How to do it...
Define live page requirements
Create and publish to the dashboard
Refine dashboard layout
How it works...
Live page slicers
Deploying content from Excel and SSRS to Power BI
Getting ready
How to do it...
Publish and pin excel objects
Pin SSRS report items
Adding data alerts and email notifications to dashboards
How to do it...
Configure data alert
Automate email notification
How it works...
Getting Serious with Date Intelligence
Introduction
Building a complete date dimension table
Getting ready
How to do it...
Date dimension design
Required date dimension columns
Date dimension planning and design
Add date intelligence columns via SQL
How it works...
Date intelligence columns
Loading the date dimension
There's more...
Role playing date dimensions
Surrogate key date conversion
Prepping the date dimension via the Query Editor
How to do it...
Date dimension M Query
Add the date intelligence column via join
How it works...
Date dimension M query
DirectQuery support
Authoring date intelligence metrics across granularities
Getting ready
How to do it...
Current time period measures
Prior time period measures
Dynamic prior period measure
How it works...
Current and prior time period measures
Developing advanced date intelligence metrics
How to do it...
Count of days without sales
Dynamic Prior Year-to-Date
How it works...
Dynamic prior period intelligence
Simplifying date intelligence with DAX queries and calculated tables
How to do it...
Role playing date dimensions via calculated tables
Date table logic query
How it works...
Date table logic query
Adding a metric placeholder dimension
How to do it...
Metric placeholder dimension query
Measure group table
Parameterizing Power BI Solutions
Introduction
Creating dynamic and portable Power BI reports
Getting ready
How to do it...
Single and multiple URL parameters
Dynamic embedded URLs
There's more...
Dashboards with custom URLs
See also
Filtering queries with parameters
Getting ready
How to do it...
Trailing days query parameter filter
Multi-parameter query filters
How it works...
Query folding of parameter value filters
There's more...
Power BI Service support
Preserving report metadata with Power BI templates
Getting ready
How to do it...
Template parameters
Export template
Converting static queries into dynamic functions
How to do it...
There's more...
Local resource usage
Parameterizing your data sources
Getting ready
How to do it...
SQL Server database
Excel filename and path
Stored procedure input parameters
Generating a list of parameter values via queries
How to do it...
Dynamic date parameter query
Product subcategories parameter query
There's more...
DirectQuery support
Capturing user selections with parameter tables
How to do it...
Sales plan growth scenarios
There's more...
Scenario specific measures
Building a forecasting process with What if analysis capabilities
Getting ready
How to do it...
Forecast variables from Excel
Power BI Desktop forecast model
Source connection and unpivoted forecast tables
Apply the forecast to historical values
Allocate the forecast according to the dimension variable inputs
Create relationships, measures, and forecast visuals
Test and deploy forecasting tool
How it works...
Implementing Dynamic User-Based Visibility in Power BI
Introduction
Capturing the current user context of Power BI content
Getting ready
How to do it...
How it works...
Power BI authentication
There's more...
USERNAME() versus USERPRINCIPALNAME()
See also
Defining RLS roles and filtering expressions
Getting ready
How to do it...
United States online Bike Sales Role
Europe reseller sales - mountain and touring
Deploy security roles to Power BI
How it works...
Filter transfer via relationships
There's more...
Managing security
Dynamic columns and central permissions table
Designing dynamic security models in Power BI
Getting ready
How to do it...
There's more...
Performance impact
Building dynamic security in DirectQuery data models
Getting ready
How to do it...
How it works...
Dynamic security via relationship filter propagation
There's more...
Bidirectional security relationships
Displaying the current filter context in Power BI reports
How to do it...
Dimension values selected
Dimension values remaining
How it works...
FILTERS() and CONCATENATEX()
Avoiding manual user clicks with user-based filtering logic
Getting ready
How to do it...
How it works...
There's more...
Personal filters feature coming to Power BI apps
Applying Advanced Analytics and Custom Visuals
Introduction
Incorporating advanced analytics into Power BI reports
How to do it...
Clustered column chart
Line chart
How it works...
Analytics pane measures
There's more...
Analytics pane limitations
See also
Enriching Power BI content with custom visuals and quick insights
Getting ready
How to do it...
Bullet chart custom visual
Scoped quick insights
How it works...
There's more...
Quick insights in Power BI Desktop
Quick insights on published datasets
Creating geospatial mapping visualizations with ArcGIS maps for Power BI
Getting ready
How to do it...
Single field address
Customer clustering Map
There's more...
ArcGIS map field wells
Conditional formatting logic
See also
Configuring custom KPI and slicer visuals
Getting ready
How to do it...
Dual KPI - headcount and labor expense
Chiclet Slicer - Sales Territory Country
There's more...
Chiclet slicer custom visual
Building animation and story telling capabilities
Getting ready
How to do it...
Scatter chart with play axis
ArcGIS map timeline
Pulse chart custom visual
There's more...
Bookmarks
Play axis custom visual
Storytelling custom visuals
Embedding statistical analyses into your model
Getting ready
How to do it...
Regression table and measures
Residuals table and measures
Regression report
How it works...
Statistical formulas
DAX calculated tables
See also
Creating and managing Power BI groupings and bins
How to do it...
First purchase date grouping
Days since last purchase grouping
Detecting and analyzing clusters
Getting ready
How to do it...
Create clusters
Analyze the clusters
How it works...
RFM - recency, frequency, monetary
Clustering algorithm and limits
There's more...
R clustering custom visuals
Scatter chart-based clustering
Forecasting and visualizing future results
Getting ready
How to do it...
Monthly forecast via date hierarchy
Weekly sales forecast analysis
How it works...
Exponential smoothing
Dynamic week status column
There's more...
Forecast requirements
Using R functions and scripts to create visuals within Power BI
Getting ready
How to do it...
Base graphics histogram
ggplot2 histogram
How it works...
Automatic duplicate removal
Filter context
There's more...
See also
Developing Solutions for System Monitoring and Administration
Introduction
Creating a centralized IT monitoring solution with Power BI
Getting ready
How to do it...
How it works...
Wait Stats and instance configuration data source setup
There's more...
Query Store integration
DirectQuery real-time monitoring datasets
See also
Constructing a monitoring visualization and analysis layer
Getting ready
How to do it...
How it works...
Relative date filtering
There's more...
Top 10 slowest queries via Query Store
See also
Importing and visualizing dynamic management view (DMV) data of SSAS and Power BI data models
How to do it...
How it works...
Memory structures
See also
Increasing SQL Server DBA productivity with Power BI
Getting ready
How to do it...
How it works...
Query Store
See also
Providing documentation of Power BI and SSAS data models to BI and business teams
Getting ready
How to do it...
How it works...
There's more...
Power BI documentation reports via Excel
SQL Server Analysis Services (SSAS) Metadata
Analyzing performance monitor counters of the Microsoft on-premises data gateway and SSAS tabular databases
Getting ready
How to do it...
SSAS tabular memory reporting
On-premises data gateway counters
How it works...
SSAS tabular memory limits
On-premises data gateway workloads
There's more...
High availability and load balancing for the on-premises data gateway
Reduce network latency via Azure ExpressRoute and Azure Analysis Services
See also
Analyzing Extended Events trace data with Power BI
Getting ready
How to do it...
How it works...
Self-service Extended Events analysis
There's more...
SQL Server Profiler versus Extended Events
Additional event session integration
See also
Visualizing log file data from SQL Server Agent jobs and from Office 365 audit searches
Getting ready
How to do it...
Power BI Audit Log Integration
SQL Server Agent log integration
How it works...
PowerShell search for Power BI audit log
SQL Server agent tables
There's more...
Power BI usage reporting
See also
Enhancing and Optimizing Existing Power BI Solutions
Introduction
Enhancing the scalability and usability of a data model
Getting ready
How to do it...
Identify expensive columns and quick wins
Normalize large dimensions
Sort imported fact tables
How it works...
Columnar database
Run-length encoding (RLE) compression via Order By
Segment elimination
There's more...
Minimize loaded and refreshed queries
Revising DAX measures to improve performance
Getting ready
How to do it...
Improper use of FILTER()
Optimizing OR condition measures
How it works...
DAX query engine - formula and storage
There's more...
DAX variables for performance
DAX as a query language
Pushing query processing back to source systems
Getting ready
How to do it...
Query folding analysis process
Query folding redesign
How it works...
Query folding factors
Native SQL queries
There's more...
Parallel loading of tables
Improving folded queries
Strengthening data import and integration processes
How to do it...
Data source consolidation
Error handling, comments, and variable names
Handling missing fields
How it works...
MissingField.UseNull
See also
Isolating and documenting DAX expressions
Getting ready
How to do it...
Reseller Margin % with variables
Variable table filters
How it works...
Reseller Margin % with variables
There's more...
DAX Formatter in DAX Studio
Deploying and Distributing Power BI Content
Introduction
Preparing a content creation and collaboration environment in Power BI
How to do it...
Evaluate and plan for Power BI deployment
Set up a Power BI service deployment
How it works...
Premium capacity nodes - frontend cores and backend cores
There's more...
Scaling up and scaling out with Power BI Premium
See also
Managing migration of Power BI content between development, testing, and production environments
Getting ready
How to do it...
Staged deployment overview
Development environment
Production environment
How it works...
Automated report lifecycle - clone and rebind report APIs
OneDrive for business synchronization
Version restore in OneDrive for business
See also
Sharing Power BI dashboards with colleagues
Getting ready
How to do it...
How it works...
Managing shared dashboards
There's more...
Analyze shared content from Excel
Sharing dashboards from Power BI mobile apps
Configuring Power BI app workspaces
Getting ready
How to do it...
How it works...
App workspaces and apps
App workspaces replace group workspaces
There's more...
Power BI premium capacity admins
See also
Configuring refresh schedules and DirectQuery connections with the on-premises data gateway
Getting ready
How to do it...
Scheduled refresh for import mode dataset
Configure data sources for the on-premises data gateway
Schedule a refresh
DirectQuery dataset
Configure data sources for the on-premises data gateway
Configure the DirectQuery dataset
How it works...
Dataset refreshes
Dashboard and report cache refreshes
There's more...
Refresh limits: Power BI premium versus shared capacity
Trigger refreshes via data refresh APIs in the Power BI Service
See also
Creating and managing Power BI apps
Getting ready
How to do it...
Publishing an app
Distributing and installing the app
How it works...
App workspaces to apps
There's more...
Apps replacing content packs
Building email subscriptions into Power BI deployments
Getting ready
Determine feasibility - recipient, distribution method, and content
How to do it...
Create dashboard and report subscriptions
Manage subscriptions
There's more...
See also
Publishing Power BI reports to the public internet
Getting ready
How to do it...
How it works...
Publish to web report cache
There's more...
Embed in SharePoint online
See also
Enabling the mobile BI experience
How to do it...
Enhance basic mobile exploration and collaboration
Enable advanced mobile BI experiences
How it works...
Responsive visualizations
There's more...
Apple watch synchronization
SSRS 2016 on-premises via Power BI mobile apps
Filters on phone reports
See also
Integrating Power BI with Other Applications
Introduction
Integrating Excel and SSRS objects into Power BI Solutions
Getting ready
How to do it...
SSRS
Excel
There's more...
SSRS and Excel use cases
SSRS
Microsoft Excel
Migrating a Power Pivot for Excel Data Model to Power BI
Getting ready
How to do it...
How it works...
Excel items imported
There's more...
Export or upload to Power BI from Excel 2016
Upload Excel Workbook to Power BI
Export Excel Workbook to Power BI
Accessing and analyzing Power BI datasets from Excel
Getting ready
How to do it...
Cube formulas
DAX query to Power BI
How it works...
Cube Formulas
DAX query data connection
There's more...
Sharing and distribution limitations
New Excel visual types table requirement
Building Power BI reports into PowerPoint presentations
Getting ready
How to do it...
Prepare a report for PowerPoint
Export report to PowerPoint
How it works...
High resolution images and textboxes
There's more...
Embed Power BI tiles in MS Office
See also
Migrating a Power BI Data Model to SSAS Tabular
Getting ready
How to do it...
How it works...
Azure analysis services pricing and performance
There's more...
Direct import to SQL server data tools
See also
Accessing MS Azure hosted services such as Azure Analysis Services from Power BI
Getting ready
How to do it...
How it works...
Report level measures for live connections to SSAS
Client libraries for Azure Analysis Services
There's more...
Power BI premium DirectQuery and SSAS live connection query limits
See also
Using Power BI with Microsoft Flow and PowerApps
Getting ready
How to do it...
Streaming Power BI dataset via MS Flow
How it works...
Microsoft Flow
There's more...
Write capabilities and MS Flow premium
PowerApps Studio and mobile applications
See also
Preface
Microsoft Power BI is a business intelligence and analytics platform consisting of applications and services designed to provide coherent visual, and interactive insights into 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. You'll 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.
What this book covers
Chapter 1, Configuring Power BI Development Tools, covers the installation and configuration of the primary tools and services that BI professionals utilize to design and develop Power BI content, including Power BI Desktop, the On-Premises Data Gateway, DAX Studio, and the Power BI Publisher for Excel.
Chapter 2, Accessing and Retrieving Data, dives into Power BI Desktop's Get Data experience and walks through the process of establishing and managing data source connections and queries.
Chapter 3, Building a Power BI Data Model, explores the primary processes of designing and developing robust data models.
Chapter 4, Authoring Power BI Reports, develops and describes the most fundamental report visualizations and design concepts. Additionally, guidance is provided to enhance and control the user experience when consuming and interacting with Power BI reports in the Power BI service and on mobile devices.
Chapter 5, Creating Power BI Dashboards, covers Power BI dashboards constructed to provide simple at-a-glance monitoring of critical measures and high-impact business activities.
Chapter 6, Getting Serious with Date Intelligence, contains three recipes for preparing a data model to support robust date intelligence and two recipes for authoring custom date intelligence measures.
Chapter 7, Parameterizing Power BI Solutions, covers both standard parameterization features and techniques in Power BI as well as more advanced custom implementations.
Chapter 8, Implementing Dynamic User-Based Visibility in Power BI, contains detailed examples of building and deploying dynamic, user-based security for both import and DirectQuery datasets, as well as developing dynamic filter context functionality to enhance the user experience.
Chapter 9, Applying Advanced Analytics and Custom Visuals, contains a broad mix of recipes highlighting many of the latest and most popular custom visualization and advanced analytics features of Power BI.
Chapter 10, Developing Solutions for System Monitoring and Administration, highlights the most common and impactful administration data sources, including Windows Performance Monitor, SQL Server Query Store, the Microsoft On-Premises Data Gateway, the MSDB system database, and Extended Events.
Chapter 11, Enhancing and Optimizing Existing Power BI Solutions, contains top data modeling, DAX measure, and M query patterns to enhance the performance, scalability, and reliability of Power BI datasets.
Chapter 12, Deploying and Distributing Power BI Content, contains detailed examples and considerations in deploying and distributing Power BI content via the Power BI service and Power BI mobile applications.
Chapter 13, Integrating Power BI with Other Applications, highlights new and powerful integration points between Power BI and SSAS, SSRS, Excel, PowerPoint, PowerApps, and Microsoft Flow.
What you need for this book
You will be guided through the chapters about the prerequisites. However, in order to work through the chapters, along with other components, you will primarily require the following:
Power BI Desktop (Free download): Recommended four-core CPU and minimum 1 GB of RAM
Windows 7-10+ or Windows Server 2008R2–2012R2
Who this book is for
This book is for BI professionals who wish to enhance their knowledge of Power BI design and development topics and to enhance the value of the Power BI solutions they deliver. Those interested in quick resolutions to common challenges and a reference guide to Power BI features and design patterns will also find this book to be a very useful resource. Some experience with Power BI will be helpful.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning. Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: Indicator columns, such as Weekday Indicator, Holiday Indicator, and Working Day Indicator.
A block of code is set as follows:
FALSE()
[Reseller Product Line] IN {Mountain
,Touring
}
[Sales Territory Group] = Europe
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Internet Net Sales (CY YTD) = CALCULATE([Internet Net Sales],
FILTER(ALL('Date'),'Date'[Calendar Year Status] = Current Calendar Year
&& 'Date'[Date] <= MAX('Date'[Date])))
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: Click on Save and then choose the new role from View as Roles on the Modeling tab
Warnings or important notes appear like this.
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply email [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files emailed directly to you. You can download the code files by following these steps:
Log in or register to our website using your email address and password.
Hover the mouse pointer on the SUPPORT tab at the top.
Click on Code Downloads & Errata.
Enter the name of the book in the Search box.
Select the book for which you're looking to download the code files.
Choose from the drop-down menu where you purchased this book from.
Click on Code Download.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR / 7-Zip for Windows
Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Microsoft-Power-BI-Cookbook. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Downloading the color images of this book
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/MicrosoftPowerBICookbook_ColorImages.pdf.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy
Piracy of copyrighted material on the internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.
Configuring Power BI Development Tools
In this chapter, we will cover the following recipes:
Configuring Power BI Desktop options and settings
Installing the On-Premises Data Gateway
Installing Power BI Publisher for Excel
Installing and configuring DAX Studio
Introduction
Power BI is a suite of business analytics tools and services that work together to access data sources, shape, analyze and visualize data, and share insights. Although not all tools are required for all projects or deployments of Power BI, synergies are available by utilizing the unique features of multiple tools as part of integrated solutions encompassing diverse data sources and visualization types.
In this chapter, we walk through the installation and configuration of the primary tools and services BI professionals utilize to design and develop Power BI content including Power BI Desktop, the On-Premises Data Gateway, DAX Studio, and the Power BI Publisher for Excel. Additionally, as Power BI tools and services are regularly updated with new features and enhancements, resources are identified to stay up-to-date and to best take advantage of these tools for your projects.
It's assumed that the reader has access to a Power BI Pro license, rights to download and install (or allow installation) the development tools on their machine, and has the necessary access and rights to deploy and manage content in the Power