Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Expert Data Modeling with Power BI: Enrich and optimize your data models to get the best out of Power BI for reporting and business needs
Expert Data Modeling with Power BI: Enrich and optimize your data models to get the best out of Power BI for reporting and business needs
Expert Data Modeling with Power BI: Enrich and optimize your data models to get the best out of Power BI for reporting and business needs
Ebook1,207 pages7 hours

Expert Data Modeling with Power BI: Enrich and optimize your data models to get the best out of Power BI for reporting and business needs

Rating: 0 out of 5 stars

()

Read preview

About this ebook

This book is a comprehensive guide to understanding the ins and outs of data modeling and how to create full-fledged data models using Power BI confidently. In this new, fully updated edition, you'll learn how to connect data from multiple sources, understand data, define and manage relationships between data, and shape data models to gain deep and detailed insights about your organization. As you advance through the chapters, the book will demonstrate how to prepare efficient data models in the Power Query Editor and use simpler DAX code with new data modeling features. You'll explore how to use the various data modeling and navigation techniques and perform custom calculations using the modeling features with the help of real-world examples. Finally, you'll learn how to use some new and advanced modeling features to enhance your data models to carry out a wide variety of complex tasks. Additionally, you'll learn valuable best practices and explore common data modeling complications and the solutions to supercharge the process of creating a data model in Power BI and build better-performing data models. By the end of this Power BI book, you'll have gained the skills you need to structure data coming from multiple sources in different ways to create optimized data models that support high-performing reports and data analytics.

LanguageEnglish
Release dateApr 28, 2023
ISBN9781803245393
Expert Data Modeling with Power BI: Enrich and optimize your data models to get the best out of Power BI for reporting and business needs

Related to Expert Data Modeling with Power BI

Related ebooks

Data Modeling & Design For You

View More

Related articles

Reviews for Expert Data Modeling with Power BI

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Expert Data Modeling with Power BI - Soheil Bakhshi

    cover.png

    Expert Data Modeling with Power BI

    Second Edition

    Enrich and optimize your data models to get the best out of Power BI for reporting and business needs

    Soheil Bakhshi

    BIRMINGHAM—MUMBAI

    Expert Data Modeling with Power BI

    Second Edition

    Copyright © 2023 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 or its dealers and distributors, will be held liable for any damages caused or alleged to have been 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.

    Senior Publishing Product Manager: Devika Battike

    Acquisition Editor – Peer Reviews: Gaurav Gavas

    Project Editor: Namrata Katare

    Content Development Editor: Rebecca Robinson

    Copy Editor: Safis Editing

    Technical Editor: Aneri Patel

    Proofreader: Safis Editing

    Indexer: Manju Arasan

    Presentation Designer: Ganesh Bhadwalkar

    Developer Relations Marketing Executive: Monika Sangwan

    First published: May 2021

    Second edition: April 2023

    Production reference: 2080523

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham

    B3 2PB, UK.

    ISBN: 978-1-80324-624-6

    www.packt.com

    I dedicate this book to my lovely wife, Elica Mehr, and our precious daughter, Avina. Without their unconditional support, none of this would have been possible. I also owe this success to my parents, who always believed in me and encouraged me to follow my dreams.

    Foreword

    I am delighted to introduce the new edition of this book by Soheil, an MVP and Power BI expert. This book is a comprehensive guide for anyone who wants to learn Power BI through practical exercises. It covers a wide range of topics, from data modeling and visualization to advanced features and best practices. Whether a beginner or an expert, you will find something useful and interesting in this book. Power BI is the leading platform and tool for enterprise and self-service BI. It is powerful, flexible, and easy to use. This new edition has been updated to reflect the latest changes and developments in Power BI. Some chapters have been completely revamped, and three new chapters have been added to cover new topics. You will learn how to deal with some data warehousing concepts in Power BI, such as SCDs and degenerate dimensions, how to use dataflows to create reusable curated data, and how to leverage DirectQuery to Power BI Datasets and Analysis Services in Composite Models. You will also discover new options, features, and DAX functions that can enhance your data analysis and reporting. This book is designed to help you learn by example. Every concept is explained using clear and concise examples that you can follow along. You will also find tips and tricks to save you time and effort. I highly recommend this book to anyone who wants to master Power BI and gain valuable insights from their data.

    Christian Wade

    Principal Program Manager, Microsoft

    Contributors

    About the author

    Soheil Bakhshi is the founder of Data Vizioner, a Microsoft Data Platform MVP, an expert in data analytics, an author, a blogger, and a speaker. He is the author of Expert Data Modeling with Power BI and the Power BI for Intermediates e-book. Soheil has over 20 years of experience in data analysis and is a thought leader in the industry, working as a consultant, trainer, and solution architect for various clients across different industries. He is passionate about data and analytics and enjoys learning new technologies and techniques to deliver innovative solutions.

    About the reviewers

    Ana María Bisbé York is a BI consultant and trainer with more than 25 years of industry experience, from developing desktop solutions in FoxPro to data analysis and BI consulting and training. She has a degree in Economic Cybernetics from Moscow’s State University of Management in the former USSR, and a Master’s degree in BI from the University of Alcala, Spain. She is currently an independent consultant specializing in the data world on Microsoft technologies, including modeling and data analysis with SQL Server BI, Excel BI, Azure ML, R, and Power BI.

    Ana is a Microsoft Data Platform MVP and Microsoft Partner in Power BI, as well as a LinkedIn Learning trainer and author of Curso Power BI (Spanish) with ANAYA. She is often a speaker, organizer, or attendee at various technical events and forums.

    She was awarded the Teckfluencer award by Globant Award Spain in 2022.

    I am grateful to all the people who have contributed to my professional and personal training.

    Thank you to my family for their patience and support.

    Ahmed Oyelowo is a Microsoft-certified Power BI data analyst associate and Microsoft-certified Azure enterprise data analyst who has developed cutting-edge BI and data analysis solutions for various corporate clients. Having started his career in banking, Ahmed moved on to consulting, where he gained data analysis and training experience. He has over 6 years of experience in delivering data analysis training and solutions and is currently a managing partner and the lead trainer and consultant at Foresight BI & Analytics Global Solutions.

    Ahmed is a 3-time recipient of the prestigious Microsoft Most Valuable Professional (MVP) award under the Data Platform category for his technical contributions to Power BI communities. He is also a Microsoft Certified Trainer and has taught various data analysis and Power BI courses—his Power BI course on Udemy has been taken by over 80,000 students in less than 3 years, and has been tagged as a Best Seller by Udemy on several occasions.

    My sincere appreciation to my Creator for the gift of all required to complete this review. I must also thank my dearest wife, Kafayat Oyelowo, and my lovely daughter, Yusraa Oyelowo, for their support and understanding while I was spending time away reviewing the best Power BI book for Power BI developers.

    Finally, to the author, Soheil Bakshi (MVP), and Packt Publishing for the opportunity to review (I say again) the best Power BI book for Power BI developers.

    Anil Maharjan is a Microsoft Data Platform MVP. He has a BE in Computer Engineering and Data Science Specialization from Coursera, Johns Hopkins University and over 12 years of development and implementation experience in the healthcare data analytics and telecommunication industries as a BI developer, database consultant, senior BI engineer, and senior data engineer.

    He is a frequent blogger and speaker at local SQL Server user groups and Power BI user groups, in addition to speaking at SQL Saturday, Data and BI Summit 2018 (Dublin), Microsoft Ignite 2019 (Singapore), Power Platform Summit 2019 (Australia), and other SQL and Power BI events. He is also the user group leader of the Nepal Power BI user group, and was a program committee member for PASS Summit 2014 and DATA and BI Summit 2018 (Dublin) and a committee track leader for Power Platform Summit 2019 (Australia).

    Anil is the author of the popular Power BI MVP Book, and blogs at anilmaharjanonbi.wordpress.com.

    I am extremely grateful to my parents and family for their love, prayers, and care, and their sacrifices to educate and prepare me for my future. I am very much thankful to my wife and daughter for their love, understanding, and support. Special thanks to my wife Deepa for suggesting I review this book, and for her love and support.

    Join us on Discord!

    Join The Big Data and Analytics Community on the Packt Discord Server!

    Hang out with 558 other members and enjoy free voice and text chat.

    https://packt.link/ips2H

    Contents

    Preface

    Who this book is for

    What this book covers

    Get in touch

    Section I: Data Modeling in Power BI

    Introduction to Data Modeling in Power BI

    Understanding the Power BI layers

    The data preparation layer (Power Query)

    The data model layer

    The Data view

    The Model view

    The data visualization layer

    The Report view

    How data flows in Power BI

    What data modeling means in Power BI

    Semantic model

    Building an efficient data model in Power BI

    Star schema (dimensional modeling) and snowflaking

    Transactional modeling versus star schema modeling

    Snowflaking

    Understanding denormalization

    Power BI licensing considerations

    Maximum size of an individual dataset

    Incremental data load

    Hybrid tables

    Calculation groups

    Shared datasets

    Power BI Dataflows

    Power BI Datamarts

    The iterative data modeling approach

    Conducting discovery workshops

    Data preparation based on the business logic

    Data modeling

    Testing the logic

    Demonstrating the business logic in basic data visualizations

    Thinking like a professional data modeler

    Summary

    Data Analysis eXpressions and Data Modeling

    Understanding virtual tables

    Creating calculated tables

    Visually displaying the results of virtual tables

    Creating calculated tables in Power BI Desktop

    Using DAX Studio

    Understanding relationships in virtual tables

    Time intelligence and data modeling

    Detecting valid dates in the date dimension

    Period-over-period calculations

    Implementing dynamic measure selection with Fields Parameters

    Generating the Date dimension with DAX

    Marking a Date table as a date table

    Creating a time dimension with DAX

    Summary

    Section II: Data Preparation in Query Editor

    Data Preparation in Power Query Editor

    Introducing the Power Query M formula language in Power BI

    Power Query is CaSe-SeNsItIvE

    Queries

    Expressions

    Values

    Primitive values

    Structured values

    Types

    Primitive types

    Custom types

    Introduction to Power Query Editor

    Queries pane

    Tables

    Custom functions

    Query parameters

    Constant values

    Groups

    Query Settings pane

    Query Properties

    Applied Steps

    Data View pane

    Status bar

    Advanced Editor

    Introduction to Power Query features for data modelers

    Column quality

    Column distribution

    Column profile

    Understanding query parameters

    Understanding custom functions

    Recursive functions

    Summary

    Getting Data from Various Sources

    Getting data from common data sources

    Folders

    CSV/Text/TSV

    Excel

    Excel file stored in local drive

    Excel file stored in SharePoint Online

    Power BI datasets

    Power BI dataflows

    Power BI Datamarts

    SQL Server

    SQL Server Analysis Services and Azure Analysis Services

    SSAS multidimensional/tabular

    AAS

    OData feed

    Dataverse

    Understanding data source certification

    Bronze

    Silver

    Gold/Platinum

    Working with connection modes

    Data Import

    Applications

    Limitations

    DirectQuery

    Applications

    Limitations

    Connect Live

    Applications

    Limitations

    Working with storage modes

    Understanding dataset storage modes

    Summary

    Common Data Preparation Steps

    Data type conversion

    Splitting a column by delimiter

    Merging columns

    Adding a custom column

    Adding a column from examples

    Duplicating a column

    Filtering rows

    Working with Group By

    Appending queries

    Merging queries

    Duplicating and referencing queries

    Replacing values

    Extracting numbers from text

    Dealing with Date, DateTime, and DateTimeZone

    Pivoting tables

    Summary

    Star Schema Preparation in Power Query Editor

    Identifying dimensions and facts

    Understanding business requirements

    Number of tables in the data source

    The linkages between existing tables

    Finding the lowest required grain of Date and Time

    Defining dimensions and facts

    Determining the potential dimensions

    Determining the potential facts

    Creating Dimension tables

    Geography

    Sales order

    Product

    Currency

    Customer

    Sales Demographic

    Date

    Time

    Creating Date and Time dimensions – Power Query versus DAX

    Creating fact tables

    Summary

    Data Preparation Common Best Practices

    Consider loading a proportion of data

    Appreciate case sensitivity in Power Query

    Be mindful of query folding and its impact on data refresh

    Understanding query folding

    DirectQuery and Dual storage modes and query folding

    Data sources and query folding

    Indications for query folding

    Query folding best practices

    Using SQL statements

    Push the data preparation to the source system when possible

    Disabling View Native Query does not necessarily mean a transformation step is not folded

    Organize queries in the Power Query Editor

    Follow data type conversion best practices

    Data type conversion can affect data modeling

    Avoid having columns with any data type

    Include the data type conversion in the step when possible

    Consider having only one data type conversion step

    Optimize query size

    Remove unnecessary columns and rows

    Summarization (Group by)

    Disabling query load

    Use query parameters

    Parameterizing connections

    Restricting the row counts in development for large tables

    Define key columns in queries

    Use naming conventions

    Summary

    Section III: Data Modeling

    Data Modeling Components

    Data modeling in Power BI Desktop

    Understanding tables

    Table properties

    Featured tables

    Calculated tables

    Understanding fields

    Data types

    Custom formatting

    Columns

    Calculated columns

    Grouping and binning columns

    Column properties

    Hierarchies

    Measures

    Implicit measures

    Explicit measures

    Textual measures

    Using relationships

    Primary keys/foreign keys

    Handling composite keys

    Relationship cardinalities

    One-to-one relationships

    One to many relationships

    Many to many relationships

    Filter propagation behavior

    Bidirectional relationships

    Summary

    Star Schema and Data Modeling Common Best Practices

    Dealing with many-to-many relationships

    Many-to-many relationships using a bridge table

    Hiding the bridge table

    Avoiding bidirectional relationships

    Dealing with inactive relationships

    Reachability via multiple filter paths

    Multiple direct relationships between two tables

    Using configuration tables

    Segmentation

    Dynamic color coding with measures

    Avoiding calculated columns when possible

    Organizing the model

    Hiding insignificant model objects

    Hiding unused fields and tables

    Hiding key columns

    Hiding implicit measures

    Hiding columns used in hierarchies when possible

    Creating measure tables

    Using folders

    Creating a folder in multiple tables in one go

    Placing a measure in various folders

    Creating subfolders

    Reducing model size by disabling auto date/time

    Summary

    Section IV: Advanced Data Modeling

    Advanced Data Modeling Techniques

    Using aggregations

    Implementing aggregations for non-DirectQuery data sources

    Implementing aggregation at the Date level

    Implementing aggregation at the Year and Month level

    Using Agg Awareness

    Creating an aggregation table

    Loading tables in DirectQuery mode

    Creating relationships

    Setting the aggregation table and its related dimensions’ storage mode

    Managing aggregation

    Testing the aggregation

    Implementing multiple aggregations

    Important notes about aggregations

    Incremental refresh and hybrid tables

    Configuring incremental refresh policy and hybrid table in Power BI Desktop

    Testing the incremental refresh

    Important notes about incremental refresh and hybrid tables

    Parent-Child hierarchies

    Identify the depth of the hierarchy

    Creating hierarchy levels

    Implementing roleplaying dimensions

    Using calculation groups

    Requirements

    Terminology

    Implementing calculation groups to handle time intelligence

    Testing calculation groups

    Fixing the format string issue

    DAX functions for calculation groups

    Summary

    Row-Level and Object-Level Security

    What RLS and OLS mean in data modeling

    Terminology

    Roles

    Rules

    Enhanced row-level security editor

    Validating roles

    Assigning members to roles in the Power BI Service

    Assigning members to roles in Power BI Report Server

    RLS implementation flow

    Common RLS implementation approaches

    Static RLS implementation

    Dynamic RLS implementation

    Restricting unauthorized users from accessing data

    Managers can access their team members’ data in parent-child hierarchies

    Getting the user’s login data from another source

    Introduction to OLS

    OLS implementation flow

    OLS implementation

    Validating roles

    Assigning members and validating roles in the Power BI Service

    RLS and OLS implementation in a single model

    Considerations in using RLS and OLS

    Summary

    Dealing with More Advanced Data Warehousing Concepts in Power BI

    Dealing with SCDs

    SCD type zero (SCD 0)

    SCD type 1 (SCD 1)

    SCD type 2 (SCD 2)

    Dealing with degenerate dimensions

    Summary

    Introduction to Dataflows

    Introduction to Dataflows

    Scenarios for using Dataflows

    Dataflow terminology

    Create Dataflows

    Create new entities

    Create linked tables from other Dataflows

    Create computed entities

    Configure incremental data refresh in Dataflows

    Export/import Dataflows

    Export Dataflows

    Import Dataflows

    No-code/low-code experience

    Query plans in Dataflows

    Summary

    DirectQuery Connections to Power BI Datasets and Analysis Services in Composite Models

    Introduction to composite models

    Enabling DirectQuery for live connections

    Allow DirectQuery connections to Power BI datasets in the Power BI service

    New terminologies

    Chaining

    Chain length

    RLS in composite models with DirectQuery to Power BI datasets

    Setting dataset permissions for contributors (report writers)

    Summary

    New Options, Features, and DAX Functions

    Field parameters

    Introduction to Power BI Datamarts

    What is a Datamart?

    What is Power BI Datamarts?

    Demystifying Power BI Datamart misunderstandings

    The Datamart Editor

    Create a simple Power BI Datamart

    Load the data into the Datamart

    Build the data model in Datamarts

    Analyze Datamarts in the Datamart Editor

    Analyze Datamarts in SQL client tools

    RLS in Datamarts

    New DAX functions

    NETWORKDAYS()

    EVALUATEANDLOG()

    Window functions

    PARTITIONBY()

    ORDERBY()

    INDEX()

    OFFSET()

    WINDOW()

    Summary

    Other Books You May Enjoy

    Index

    Landmarks

    Cover

    Index

    Preface

    Nowadays, information is easily accessible via the Internet. A quick search of What is Power BI? results in millions of websites and articles about the topic. Here is a condensed definition of Power BI:

    Power BI is the data platform subset of a larger Software as a Service (SaaS) platform called Power Platform, offered by Microsoft.

    To better understand the preceding definition, we need to know what data platform and SaaS applications are.

    A data platform is a comprehensive software framework designed to store, manage, integrate, analyze, and visualize large volumes of data from various sources in a secure, reliable, and scalable manner, enabling organizations to gain insights, make data-driven decisions, and improve their operations and customer experiences. Power BI has all the characteristics of a data platform.

    A SaaS application is a subscription-based software solution fully hosted in the cloud that organizations rent and use via the Internet. Power BI is a SaaS application that is subscription-based and fully hosted in Microsoft’s cloud system. It offers various subscription plans, each with its own features, limitations, and toolsets.

    It is critical to understand that the core of a data platform is the data itself. Spending time and money on a data platform is worth nothing without paying attention to how the data is stored, prepared, and modeled for analysis. The Power BI platform provides the required tools for that, and we need to have the knowledge to effectively and efficiently use those tools to establish the foundations of our data platform successfully.

    This book will guide you to understand the ins and outs of data modeling and the required data preparations. This book teaches you how to connect to multiple data sources, understand the data and its interrelationships, and reshape it to create efficient data models. You will also learn about data exploration and navigation techniques to identify new metrics and perform custom calculations using various data modeling techniques. As you advance through the chapters, the book will demonstrate how to create full-fledged data models, enabling you to develop efficient and performant DAX code with new data modeling features. The book uses various real-world scenarios to ensure you learn practical techniques to solve business challenges by building optimal data models and being flexible in changing existing ones to meet evolving business requirements.

    Finally, you’ll learn how to use some new and advanced modeling features to enhance your data models to carry out a wide variety of complex tasks. By the end of this book, you will have gained the skills to structure data from multiple sources in different ways and create optimized data models that support reporting and data analytics requirements.

    Who this book is for

    If you are a Power BI user who wants to learn how to design and build effective data models for your reports and dashboards, this book is for you. Whether you are a beginner or an advanced user, you will find practical and useful tips and techniques to improve your data modeling skills and solve common challenges. You will also learn how to apply best practices and optimize your data model performance. This book is suitable for anyone who works with data and wants to leverage the power of Power BI to create insightful and interactive data visualizations. This book is also ideal for data analysts, business analysts, and BI professionals who have a basic understanding of Power BI and want to learn advanced data modeling techniques to design scalable and optimized data models for their business needs. Additionally, the book may also be beneficial to database developers and data engineers who want to learn how to integrate Power BI into their data architecture and create efficient data models for their organization.

    What this book covers

    Chapter 1, Introduction to Data Modeling in Power BI, briefly describes different functionalities of Power BI and why data modeling is important. This chapter also reveals some important notes to be considered around Power BI licensing, which could potentially affect your data model. This chapter introduces an iterative data modeling approach, which guarantees an agile Power BI implementation.

    Chapter 2, Data Analysis eXpressions and Data Modeling, does not discuss DAX in detail, as in Part 3 and 4 of this book DAX is heavily used to solve different data modeling challenges. Therefore, we’ll only focus on the DAX functionalities that are harder to understand and are very relevant to data modeling. This chapter starts with a quick introduction to DAX, then we jump straight into virtual tables and time intelligence functionalities and their applications in real-world scenarios.

    Chapter 3, Data Preparation in Power Query Editor, quickly explains the components of Power Query and their application. It expresses the importance of creating query parameters and user-defined functions along with real-world use cases and scenarios to demonstrate how powerful they are in building much more flexible and maintainable models.

    Chapter 4, Getting Data from Various Sources, explains how to get data from different data sources that are more commonly used in Power BI. Then, the importance of data source certification is explained, which helps you set your expectations on the type of data you’re going to deal with. This is especially helpful in estimating data modeling efforts. Different connection modes are also explained in this chapter.

    Chapter 5, Common Data Preparation Steps, explains common data preparation steps along with real-world hands-on scenarios. A combination of what you have learned so far in this book and the steps discussed in this chapter gives you a strong foundation to go on to the next chapters and build your data models more efficiently.

    By learning these functionalities, you can deal with a lot of different scenarios to implement different data models.

    Chapter 6, Star Schema Preparation in Power Query Editor, explains how to prepare your queries based on the star schema data modeling approach with real-life scenarios. The Power Query M language will be heavily used in this chapter, so you will learn how to deal with real-world challenges along the way. As you have already learned common data preparation steps in the previous chapter, the majority of Power Query scenarios explained in this chapter will be easier to implement. You’ll also learn how to build dimension tables and fact tables, and how to denormalize your queries when needed.

    Chapter 7, Data Preparation Common Best Practices, explains common best practices in data preparation. Following these practices will help you build more efficient data models that are easier to maintain and more flexible to make changes to. By following these practices, you can also avoid common mistakes, which can make your life much easier.

    Chapter 8, Data Modeling Components, explains data modeling components from a Power BI perspective, along with real file examples. In this chapter, we heavily use DAX when applicable, so having a basic understanding of DAX is essential. We also have a complete star schema model in Power BI. The concept of config tables is covered, which unlocks a lot of possibilities for handling more complex business logic in the data model. The chapter ends with data modeling naming conventions.

    Chapter 9, Star Schema and Data Modeling Common Best Practices, explains common data modeling best practices to help you make better decisions while building your data model to prevent facing some known issues down the road. For instance, dealing with data type issues in key columns that are used in relationships is somewhat time-consuming to identify, but it’s very easy to prevent. So, knowing data modeling best practices helps you save a lot of maintenance time and consequently saves you money.

    Chapter 10, Advanced Data Modeling Techniques, explains special modeling techniques that solve special business requirements. A good data modeler is one who is always open to new challenges. You may face some of the advanced business requirements discussed in this chapter or you may face something different but similar. The message we want to send in this chapter is to think freely when dealing with new business challenges and try to be innovative to get the best results.

    Chapter 11, Row-Level and Object-Level Security, explains how to implement Row-Level Security (RLS) and Object-Level Security (OLS) in a Power BI data model. Dealing with RLS and OLS can be complex, and knowing how to deal with different situations requires deep knowledge of data modeling and filter propagation concepts. Our aim in this chapter is to transfer that knowledge to you so you can design and implement high-performing and low-maintenance data models.

    Chapter 12, Dealing with More Advanced Data Warehousing Concepts in Power BI, explains two concepts coming from data warehousing, Slowly Changing Dimensions (SCDs) and degenerate dimensions. This chapter also demonstrates when and how we can implement these concepts in a Power BI data model.

    Chapter 13, Introduction to Dataflows, briefly introduces Dataflows, another available feature in Power BI. This chapter is designed to cover the basics and help you to build robust building blocks for your learning journey. This chapter also explains how to export/import Dataflows, and how the no-code/low-code experience and query plan work in Dataflows.

    Chapter 14, DirectQuery Connections to Power BI Datasets and Analysis Services in Composite Models, introduces new terminologies related to composite models and discusses how to resolve more complex scenarios with fewer issues. This chapter also covers RLS challenges in composite models with DirectQuery connections to either a Power BI dataset or Azure Analysis Services and explains the challenges around setting dataset permissions for contributors after RLS is created.

    Chapter 15, New Options, Features, and DAX Functions, introduces field parameters, Power BI Datamarts, and some new DAX functions. One of the main features is Field Parameters, which allow developers to create dynamic reports where users can switch between different fields using a slicer. Additionally, the chapter introduces Power BI Datamarts, a subject-oriented subset of a data warehouse focusing on a particular business unit, department, subject area, or business functionality. This chapter also explains how RLS Power BI Datamarts are implemented. The chapter also highlights new DAX functions, including

    NETWORKDAYS()

    and

    EVALUATEANDLOG()

    , and window functions such as

    INDEX()

    ,

    OFFSET()

    , and

    WINDOW()

    .

    To get the most out of this book

    You will need to download and install the latest version of Power BI Desktop. All expressions have been tested in the March 2023 release of Power BI Desktop and should work in the later versions released on later dates. Power BI Desktop is a free application that lets you connect to various data sources, transform and model data, create visualizations, and share your work by publishing to the Power BI service. You can get Power BI Desktop in two ways:

    As a Windows app from the Microsoft Store

    As an executable desktop application downloadable directly from the Power BI website

    In addition to Power BI Desktop, you will need to install and use DAX Studio, Tabular Editor, SQL Server Management Studio SSMS, and DAX Debug Output. All of these applications are free of charge. Here are the minimum requirements for the required applications to work properly:

    Power BI Desktop:

    Hardware: A Personal Computer (PC) with at least a 1-Gigahertz (GHz) 64-bit (x64) processor, 2 GB of RAM, and 1 GB of available disk space. At least 1440x900 or 1600x900 (16:9) resolution is required. Lower resolutions such as 1024x768 or 1280x800 aren’t supported because some controls (such as closing the startup screens) display beyond those resolutions. For optimal performance, having 8 GB of RAM and a 64-bit processor is recommended.

    Software: Install the latest version of Power BI Desktop from the Microsoft Store or the Power BI website on a Windows machine with Windows 8.1 or Windows Server 2012 R2 or later. You need to have .NET Framework 4.6.2 or higher and the Microsoft Edge browser (Internet Explorer is no longer supported). Power BI Desktop automatically installs WebView2. It is recommended to use a client version of Windows, such as Windows 10, instead of Windows Server. Power BI Desktop doesn’t support Internet Explorer Enhanced Security Configuration.

    Security: You need to have a valid Power BI account to sign in to Power BI Desktop and publish reports. You also need to have permission to access the data sources and services that you want to use in your reports.

    The following are download links for Power BI Desktop:

    Power BI Desktop from the Microsoft Store: https://aka.ms/pbidesktopstore

    Power BI Desktop from the web: https://www.microsoft.com/en-us/download/details.aspx?id=58494

    You can sign up for a Power BI Service as an individual. Read more here: https://learn.microsoft.com/en-us/power-bi/fundamentals/service-self-service-signup-for-power-bi?WT.mc_id=DP-MVP-5003466.

    Since January 31, 2021, Power BI Desktop is no longer supported on Windows 7.

    Tabular Editor:

    Tabular Editor is a powerful tool to create and manage tabular models in Microsoft Analysis Services and Power BI. The vendor, Kapacity, currently offers the tool in two flavours, Tabular Editor 2.x, which is the free version, and Tabular Editor 3.x, which is the commercial paid version. In this book, we use the free version. The following are the minimum requirements for running Tabular Editor:

    Hardware: A Windows PC with at least 4 GB of RAM and 100 MB of free disk space.

    Software: Windows 7, Windows 8, Windows 10 (recommended), Windows Server 2016, Windows Server 2019 or newer, and .NET Framework 4.6 or later. Microsoft Analysis Services client libraries (installed by default with SQL Server Management Studio or Visual Studio) are also required.

    Security: Administrator rights on the PC where Tabular Editor is installed or run. Read and write permissions on the tabular model that you want to edit are also required.

    You can download Tabular Editor 2.x from here: https://github.com/TabularEditor/TabularEditor/releases/.

    DAX Studio:

    DAX Studio is a free, powerful tool from SQLBI for analyzing and optimizing DAX queries. It can connect to various data sources, such as Power BI, SQL Server Analysis Services Tabular Models, Azure Analysis Services, and Power Pivot. To use DAX Studio effectively, you need to meet some hardware, software, and security requirements as follows:

    Hardware: A Windows PC with a minimum of 4 GB of RAM and 100 MB of disk space.

    Software: Windows 7, Windows 8, Windows 10 (recommended), .NET Framework 4.7.1 or later, and Office primary interop assemblies are required. Office 2016 and later should have this enabled by default.

    Security: DAX Studio requires administrator privileges to install and update unless its portable version is used. It also requires access to the data sources that you want to connect to.

    You can download DAX Studio from here: https://daxstudio.org/downloads/.

    SQL Server Management Studio (SSMS):

    SQL Server Management Studio (SSMS) is a Graphical User Interface (GUI) tool for developing, managing, and administrating SQL Server databases and servers. You can use SSMS to create and modify database objects, run queries and scripts, monitor performance and activity, configure security and backup options, and more. SSMS is a free and downloadable offering from Microsoft that works with any edition of SQL Server. SSMS can also be used to run DAX queries when connected to an instance of SQL Server Analysis Services (SSAS) Tabular Models, Azure Analysis Services (AAS), or a premium Power BI dataset via XMLA endpoints. The following are the prerequisites to run SSMS efficiently throughout this book:

    Hardware: A Windows PC with at least a 1.8 GHz or faster x86 (Intel, AMD) processor (dual-core or better recommended), 2 GB of RAM is required (4 GB of RAM recommended), and 2.5 GB is the minimum if run on a Virtual Machine (VM). It also requires a minimum of 2 GB of available space (up to 10 GB).

    Software: Windows 10 (64-bit) version 1607 (10.0.14393) or later, Windows 11 (64-bit), Windows Server 2016 (64-bit), Windows Server 2019 (64-bit), or Windows Server 2022 (64-bit).

    Security: SSMS requires administrator privileges to install.

    SSMS is available to download from here: https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver16&WT.mc_id=DP-MVP-5003466.

    DAX Debug Output:

    DAX Debug Output is a free community tool that allows developers to view the results of DAX expressions run in Power BI Desktop. This can help troubleshoot and optimize complex DAX formulas and measures. This tool is currently in public preview and the developer has not released much information about its system requirements yet. It currently works with the Power BI Desktop August 2022 release or later. DAX Debug Output is available to download from here: https://github.com/pbidax/DAXDebugOutput/releases/tag/v0.1.0-beta.

    If you are using the digital version of this book, we advise that you type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

    Download the example code files

    The code bundle for the book is hosted on GitHub at https://github.com/PacktPublishing/Expert-Data-Modeling-with-Power-BI-Second-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

    Download the color images

    We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://packt.link/XAVMa.

    Conventions used

    There are a number of text conventions used throughout this book.

    CodeInText

    : Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: "Open the

    Adventure Works

    ,

    Internet Sales.pbix file

    ."

    A block of code is set as follows:

    Sequential Numbers = SELECTCOLUMNS( GENERATESERIES(1, 20, 1) , ID , [Value] )

    Bold: Indicates a new term, an important word, or words that you see on the screen. For instance, words in menus or dialog boxes appear in the text like this. For example: "Click New table from the Modeling tab."

    Warnings or important notes appear like this.

    Tips and tricks appear like this.

    Get in touch

    Feedback from our readers is always welcome.

    General feedback: Email

    [email protected]

    and mention the book’s title in the subject of your message. If you have questions about any aspect of this book, please email us at

    [email protected]

    .

    Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you reported this to us. Please visit http://www.packtpub.com/submit-errata, click Submit Errata, and fill in the form.

    Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at

    [email protected]

    with a link to the material.

    If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit http://authors.packtpub.com.

    Share your thoughts

    Once you’ve read Expert Data Modeling with Power BI, Second Edition, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

    Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

    Download a free PDF copy of this book

    Thanks for purchasing this book!

    Do you like to read on the go but are unable to carry your print books everywhere? Is your eBook purchase not compatible with the device of your choice?

    Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

    Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application. 

    The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

    Follow these simple steps to get the benefits:

    Scan the QR code or visit the link below

    https://packt.link/free-ebook/9781803246246

    Submit your proof of purchase

    That’s it! We’ll send your free PDF and other benefits to your email directly

    Section 1

    Data Modeling in Power BI

    In this section, we quickly introduce data modeling in Power BI from a general point of view. We assume you know what Power Query is, what DAX is, and that you know the basic concepts of the star schema. In this section, you will learn about virtual tables and time intelligence functionalities in DAX and how you can implement a powerful model with real-world scenarios.

    This section comprises the following chapters:

    Chapter 1, Introduction to Data Modeling in Power BI

    Chapter 2, Data Analysis eXpressions and Data Modeling

    1

    Introduction to Data Modeling in Power BI

    Power BI is not just a reporting tool to build sophisticated reports; it is a platform that supplies a wide range of features from data preparation to data modeling and visualization. It is also a very well-designed ecosystem, giving a variety of users the ability to contribute to their organization’s data analysis journey in many ways, from sharing datasets, reports, and dashboards to using their mobile phones to add some comments to a report, ask questions, and circulate it back to the relevant people. All of this is only possible if we take the correct steps in building our Power BI ecosystem. A very eye-catching and beautiful report is worth nothing if it shows incorrect figures or if the report is too slow to render, so the user does not have the appetite to use it.

    One of the most critical aspects of building a good Power BI ecosystem is to get the data right. In real-world scenarios, you usually get data from various data sources. Getting data from the data sources and then preparing it are just the beginning. Then, you need to develop a well-designed data model that guarantees you always represent the correct figures supporting the business logic, leading to well-performing related reports.

    In this chapter, we start learning about the different Power BI layers and how data flows between the different layers to be able to fix any potential issues more efficiently. Then, we study one of the essential aspects of Power BI implementation, data modeling. You learn more about the data modeling feature availabilities and limitations under various Power BI licensing plans. Finally, we discuss the iterative data modeling approach and its different phases.

    This chapter covers the following main sections:

    Power BI Desktop layers

    What data modeling means in Power BI

    Power BI licensing considerations for data modeling

    The iterative data modeling approach

    Understanding the Power BI layers

    As stated before, Power BI is not just a reporting tool. As this book focuses on data modeling, we will not spend much time explaining the tool itself; instead, we cover some concepts that should be pointed out. When we talk about data modeling in Power BI, we refer to Power BI Desktop as a development tool. You can think of Power BI Desktop like Visual Studio when developing an SQL Server Analysis Services (SSAS) Tabular model. Power BI Desktop is a free tool offered by Microsoft that can be downloaded from https://powerbi.microsoft.com/en-us/downloads/.

    This book refers to Power BI Desktop when mentioning Power BI unless stated otherwise.

    The following illustration shows a straightforward process we usually go through while building a report in Power BI Desktop:

    Diagram Description automatically generated

    Figure 1.1: Building a new report process in Power BI

    We use different conceptual layers of Power BI to go through the preceding processes. The following image shows where to access these layers in Power BI Desktop:

    Graphical user interface, application Description automatically generated

    Figure 1.2: Power BI layers

    Let us discuss each point in detail:

    The Power Query (data preparation) layer

    The Model layer (data model)

    The Report layer (data visualization)

    The Data tab shown in the preceding image is where we can see the actual data loaded into the data model, so it is not considered a layer in Power BI Desktop.

    To follow the following exercises, download the

    Microsoft

    Contoso

    Sales

    sample for Power BI Desktop from https://www.microsoft.com/en-us/download/confirmation.aspx?id=46801.

    The data preparation layer (Power Query)

    In this layer, we get the data from various data sources, transform and cleanse that data, and make it available for the next layer. This is the first layer that touches the data, so it is an essential part of the data journey in Power BI. In the Power Query layer, we decide which queries load data into the data model and which ones take care of data transformation and data cleansing without loading the data into the data model:

    Graphical user interface, application, table Description automatically generated

    Figure

    Enjoying the preview?
    Page 1 of 1