Вы находитесь на странице: 1из 68

Transitioning to Microsoft Power

Platform: An Excel User Guide to


Building Integrated Cloud Applications
in Power BI, Power Apps, and Power
Automate 1st Edition David Ding
Visit to download the full and correct content document:
https://ebookmass.com/product/transitioning-to-microsoft-power-platform-an-excel-us
er-guide-to-building-integrated-cloud-applications-in-power-bi-power-apps-and-power-
automate-1st-edition-david-ding/
Transitioning to
Microsoft Power
Platform
An Excel User Guide
to Building Integrated Cloud
Applications in Power BI, Power
Apps, and Power Automate

David Ding
Transitioning to Microsoft Power Platform: An Excel User Guide to
Building Integrated Cloud Applications in Power BI, Power Apps,
and Power Automate
David Ding
Sydney, NSW, Australia

ISBN-13 (pbk): 978-1-4842-9238-9 ISBN-13 (electronic): 978-1-4842-9239-6


https://doi.org/10.1007/978-1-4842-9239-6

Copyright © 2023 by David Ding


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way,
and transmission or information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos,
and images only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal
responsibility for any errors or omissions that may be made. The publisher makes no warranty,
express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Joan Murray
Development Editor: Laura Berendson
Editorial Assistant: Gryffin Winkler
Copyeditor: Kim Burton
Cover image designed by kjpargeter on Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505,
e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a
California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc
(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Print
and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is
available to readers on GitHub.
Printed on acid-free paper
To my wife, Yuan Yao, for her endless love and support
To my boys, Martin and Harry, for making me
care more about the future
To Dr. Peter Critchley for his friendship, wisdom,
and guidance
To Dmitry Osipenko for providing excellent
feedback on this book
To Joan Murray for believing in me on my first
book idea
Table of Contents
About the Author��������������������������������������������������������������������������������xv

About the Technical Reviewer����������������������������������������������������������xvii

Introduction���������������������������������������������������������������������������������������xix

Chapter 1: Power BI First Report����������������������������������������������������������1


Business Scenario������������������������������������������������������������������������������������������������3
Power BI Software Licensing��������������������������������������������������������������������������������5
Build Your First Power BI Report���������������������������������������������������������������������������7
Data and Requirements�����������������������������������������������������������������������������������7
Install Power BI Desktop���������������������������������������������������������������������������������9
Report Building������������������������������������������������������������������������������������������������9
Conclusion����������������������������������������������������������������������������������������������������������22

Chapter 2: Power BI Core Components�����������������������������������������������23


Build a Report with Power Query������������������������������������������������������������������������23
Business Scenario�����������������������������������������������������������������������������������������24
Data Processing Automation�������������������������������������������������������������������������24
Create a New Query��������������������������������������������������������������������������������������27
Combine Power Query Tables������������������������������������������������������������������������28
Add a New Column����������������������������������������������������������������������������������������33
Seamless Data Integration����������������������������������������������������������������������������34
Add a New Report Page���������������������������������������������������������������������������������35
Power Query Summary���������������������������������������������������������������������������������39

v
Table of Contents

Building a Report with a Data Model������������������������������������������������������������������39


Why a Data Model?����������������������������������������������������������������������������������������40
Implement the Data Model����������������������������������������������������������������������������42
Data Model Summary������������������������������������������������������������������������������������56
DAX: Data Analysis Expression����������������������������������������������������������������������������57
Create a Basic Measure in DAX���������������������������������������������������������������������58
Filter Context in DAX��������������������������������������������������������������������������������������63
Row Context in DAX���������������������������������������������������������������������������������������67
Create a Calendar Table Using DAX���������������������������������������������������������������69
The Calculate Function in DAX����������������������������������������������������������������������72
Date Intelligence with CALCULATE����������������������������������������������������������������77
Variables in DAX��������������������������������������������������������������������������������������������81
Organize DAX Measures��������������������������������������������������������������������������������83
DAX Summary�����������������������������������������������������������������������������������������������85
Conclusion����������������������������������������������������������������������������������������������������������85

Chapter 3: Power BI Service���������������������������������������������������������������87


Publishing and Sharing Reports��������������������������������������������������������������������������87
Business Scenario�����������������������������������������������������������������������������������������88
Sharing Risks������������������������������������������������������������������������������������������������90
A Better Way of Sharing���������������������������������������������������������������������������������93
Report-Sharing Summary����������������������������������������������������������������������������102
Automation��������������������������������������������������������������������������������������������������������102
Data Connection������������������������������������������������������������������������������������������104
Export Flat Files in a Shared Folder�������������������������������������������������������������106
Data Transformation������������������������������������������������������������������������������������108
Scheduling with Power BI Gateways�����������������������������������������������������������109
Power BI Gateway���������������������������������������������������������������������������������������110
Conclusion��������������������������������������������������������������������������������������������������������112

vi
Table of Contents

Mini-Hackathon�������������������������������������������������������������������������������������������������112
Hackathon Data�������������������������������������������������������������������������������������������113
Objectives����������������������������������������������������������������������������������������������������113
Time Limit����������������������������������������������������������������������������������������������������114

Chapter 4: Data Visualization�����������������������������������������������������������115


Chart Selection��������������������������������������������������������������������������������������������������116
Pie and Donut Charts�����������������������������������������������������������������������������������119
Column and Bar Charts��������������������������������������������������������������������������������120
Line Charts��������������������������������������������������������������������������������������������������122
Table vs. Matrix Visuals�������������������������������������������������������������������������������123
Scatter Charts����������������������������������������������������������������������������������������������125
Sunburst Diagrams��������������������������������������������������������������������������������������128
Summary�����������������������������������������������������������������������������������������������������130
Data Explanation vs. Exploration�����������������������������������������������������������������������130
Data Exploration������������������������������������������������������������������������������������������130
Data Explanation�����������������������������������������������������������������������������������������135
Summary�����������������������������������������������������������������������������������������������������137
Report Design���������������������������������������������������������������������������������������������������137
Business Scenario���������������������������������������������������������������������������������������138
Structure the Reports����������������������������������������������������������������������������������138
Design Template for Exploration Reports����������������������������������������������������145
Color Selection��������������������������������������������������������������������������������������������148
Conclusion��������������������������������������������������������������������������������������������������������153
Mini-Hackathon�������������������������������������������������������������������������������������������������153
Hackathon Data�������������������������������������������������������������������������������������������154
Objectives����������������������������������������������������������������������������������������������������154
Time Limit����������������������������������������������������������������������������������������������������154

vii
Table of Contents

Chapter 5: Power BI Governance������������������������������������������������������155


Why Governance?���������������������������������������������������������������������������������������������155
A Business Scenario������������������������������������������������������������������������������������156
Adoption-Driven Governance Framework���������������������������������������������������158
Usage Data��������������������������������������������������������������������������������������������������������160
Workspace Usage Report����������������������������������������������������������������������������160
PowerShell cmdlet and API�������������������������������������������������������������������������163
Drive User Adoption������������������������������������������������������������������������������������������167
Identify a New Usage Process���������������������������������������������������������������������168
Identify Consolidation Process��������������������������������������������������������������������169
Track Benefits���������������������������������������������������������������������������������������������������170
Effort Saved�������������������������������������������������������������������������������������������������170
Value Adds���������������������������������������������������������������������������������������������������170
Improve Development Efficiency����������������������������������������������������������������������171
Report Prioritization�������������������������������������������������������������������������������������172
Report Standardization��������������������������������������������������������������������������������172
Development Standardization���������������������������������������������������������������������180
Support Framework�������������������������������������������������������������������������������������190
Data Security����������������������������������������������������������������������������������������������������194
Access Points Analysis��������������������������������������������������������������������������������195
Data Source Connection Process����������������������������������������������������������������196
User Access Management���������������������������������������������������������������������������197
Conclusion��������������������������������������������������������������������������������������������������������198

Chapter 6: SQL for Power BI�������������������������������������������������������������199


Set up a SQL Server for Practice����������������������������������������������������������������������200
Set up a Free Azure Account�����������������������������������������������������������������������200
Set up a Sample SQL Database�������������������������������������������������������������������200
Log in to Azure Query Editor������������������������������������������������������������������������204

viii
Table of Contents

Load SQL Query in Power BI�����������������������������������������������������������������������������206


SQL Query Basics����������������������������������������������������������������������������������������������209
Query Construction Process������������������������������������������������������������������������210
SQL Query Syntax����������������������������������������������������������������������������������������215
SQL Functions���������������������������������������������������������������������������������������������219
Group By and Aggregate Function���������������������������������������������������������������227
SQL Basics Summary����������������������������������������������������������������������������������231
Predefined Variables and Tables�����������������������������������������������������������������������232
Create Variables�������������������������������������������������������������������������������������������232
Create Variables from Data��������������������������������������������������������������������������234
Create Table from Data (WITH)���������������������������������������������������������������������236
Conclusion��������������������������������������������������������������������������������������������������������237
Mini-Hackathon�������������������������������������������������������������������������������������������������238
Objective������������������������������������������������������������������������������������������������������238
Time Limit����������������������������������������������������������������������������������������������������239

Chapter 7: SharePoint Lists��������������������������������������������������������������241


Business Scenario��������������������������������������������������������������������������������������������241
Create a SharePoint List�����������������������������������������������������������������������������������242
Create a SharePoint Site�����������������������������������������������������������������������������243
Create a SharePoint List������������������������������������������������������������������������������244
Edit a SharePoint List����������������������������������������������������������������������������������������248
Standard Edit�����������������������������������������������������������������������������������������������248
Bulk Edit������������������������������������������������������������������������������������������������������250
User Access and Security���������������������������������������������������������������������������������255
Permission Level�����������������������������������������������������������������������������������������255
Groups���������������������������������������������������������������������������������������������������������261
List Permissions������������������������������������������������������������������������������������������263

ix
Table of Contents

Share the List with Users����������������������������������������������������������������������������265


List Views����������������������������������������������������������������������������������������������������265
Connection with Power BI���������������������������������������������������������������������������������268
Difference in Content�����������������������������������������������������������������������������������269
Improve Speed with Default View����������������������������������������������������������������271
Conclusion��������������������������������������������������������������������������������������������������������273

Chapter 8: First Power Apps�������������������������������������������������������������275


Business Scenario��������������������������������������������������������������������������������������������276
Power Apps Licensing���������������������������������������������������������������������������������������276
Check Access to Power Apps����������������������������������������������������������������������277
Power Apps Connectors������������������������������������������������������������������������������278
Premium Connectors�����������������������������������������������������������������������������������279
Cost and Licensing Strategies���������������������������������������������������������������������280
Power Apps with a SharePoint List��������������������������������������������������������������281
Build the First Power Apps��������������������������������������������������������������������������������281
Create an App from a SharePoint List����������������������������������������������������������282
Understanding Power Apps Studio��������������������������������������������������������������284
Understanding the Default App��������������������������������������������������������������������286
Share the Default App����������������������������������������������������������������������������������290
Build the App from a Blank Canvas�������������������������������������������������������������������292
Create a Blank Canvas App��������������������������������������������������������������������������292
Agile Mindset for App Development������������������������������������������������������������293
Establish the Initial Requirements���������������������������������������������������������������297
Add Data������������������������������������������������������������������������������������������������������298
Main Screen������������������������������������������������������������������������������������������������300
Gallery���������������������������������������������������������������������������������������������������������300
Edit Screen��������������������������������������������������������������������������������������������������307
Edit to Display Switch����������������������������������������������������������������������������������310

x
Table of Contents

Add a New Record Button���������������������������������������������������������������������������313


Save to a SharePoint List����������������������������������������������������������������������������315
Conclusion��������������������������������������������������������������������������������������������������������322

Chapter 9: Improve Power Apps�������������������������������������������������������323


The Business Scenario��������������������������������������������������������������������������������������323
Variables and Delegation����������������������������������������������������������������������������������324
Variables in Power Apps������������������������������������������������������������������������������324
Delegation���������������������������������������������������������������������������������������������������330
Color Palette������������������������������������������������������������������������������������������������������338
Apply Naming Standards����������������������������������������������������������������������������������342
Additional UI Features���������������������������������������������������������������������������������������344
Drop-down Filter�����������������������������������������������������������������������������������������345
Sorting the Gallery���������������������������������������������������������������������������������������354
Search Bar���������������������������������������������������������������������������������������������������359
Dynamic Calculation�����������������������������������������������������������������������������������������360
Basic Calculations���������������������������������������������������������������������������������������360
Calculation in a Gallery��������������������������������������������������������������������������������363
Aggregation Calculations�����������������������������������������������������������������������������365
Calculation in Collection������������������������������������������������������������������������������366
User Experience������������������������������������������������������������������������������������������������368
Have a Clear Purpose����������������������������������������������������������������������������������369
Add Interaction Feedback����������������������������������������������������������������������������370
Input Validation��������������������������������������������������������������������������������������������373
Conclusion��������������������������������������������������������������������������������������������������������377
Mini-Hackathon�������������������������������������������������������������������������������������������������378
Objective������������������������������������������������������������������������������������������������������378
Time Limit����������������������������������������������������������������������������������������������������378

xi
Table of Contents

Chapter 10: Power Automate������������������������������������������������������������379


Business Scenario��������������������������������������������������������������������������������������������379
Power Automate Licensing�������������������������������������������������������������������������������380
Power Automate Flows�������������������������������������������������������������������������������������382
Cloud Flow Overview����������������������������������������������������������������������������������������383
Email Notification����������������������������������������������������������������������������������������������387
Create a Backup������������������������������������������������������������������������������������������������396
Prepare a Backup Excel File������������������������������������������������������������������������396
Create the Backup Process�������������������������������������������������������������������������399
Test the Backup Process�����������������������������������������������������������������������������408
Fix Issues�����������������������������������������������������������������������������������������������������410
OData Filter��������������������������������������������������������������������������������������������������415
Streamline Approval Processes������������������������������������������������������������������������418
Prepare the Approver Email�������������������������������������������������������������������������419
Build the Approval Flow�������������������������������������������������������������������������������422
Integrate with Power Apps��������������������������������������������������������������������������432
Approvals Customization Options����������������������������������������������������������������434
Conclusion��������������������������������������������������������������������������������������������������������437
Mini-Hackathon�������������������������������������������������������������������������������������������������437
Objectives����������������������������������������������������������������������������������������������������437
Time Limit����������������������������������������������������������������������������������������������������438

Chapter 11: Integrated Solutions������������������������������������������������������439


Business Scenario��������������������������������������������������������������������������������������������439
Power Apps Visual in Power BI�������������������������������������������������������������������������441
Limitation of Power Apps Visual������������������������������������������������������������������441
Integrated Architecture��������������������������������������������������������������������������������442
Application Design���������������������������������������������������������������������������������������443

xii
Table of Contents

Implement the Same Page Layout��������������������������������������������������������������������445


Underlying Data�������������������������������������������������������������������������������������������445
Use Scatter Plot for Strategic Categorization����������������������������������������������447
Create an Embedded App����������������������������������������������������������������������������451
Include Decisions Back into the App�����������������������������������������������������������462
Include Decisions Back into the Report�������������������������������������������������������466
Improving the Integrated Application����������������������������������������������������������������470
Add Email Notification���������������������������������������������������������������������������������470
Add Action Status Tracker����������������������������������������������������������������������������472
Access Management�����������������������������������������������������������������������������������������480
Conclusion��������������������������������������������������������������������������������������������������������480
Mini-Hackathon�������������������������������������������������������������������������������������������������481
Objective������������������������������������������������������������������������������������������������������481
Time Limit����������������������������������������������������������������������������������������������������481
Final Thoughts���������������������������������������������������������������������������������������������������482

Index�������������������������������������������������������������������������������������������������483

xiii
About the Author
David Ding is the director and lead consultant
of SDInnovation, a consulting company that
provides customized decision support and
training services to organizations across
multiple industries. David is a certified Power
BI developer with a master’s degree in data
science. Previously, David held multiple senior
business and technical positions. This book
is part of his mission to help everyone to get
better with data.

xv
About the Technical Reviewer
Fabio Claudio Ferracchiati is a senior consultant and analyst/developer
using Microsoft technologies. He works for Bluarancio (www.bluarancio.
com). He is a Microsoft Certified Solution Developer for .NET, a Microsoft
Certified Application Developer for .NET, a Microsoft Certified Professional,
and a prolific author and technical reviewer. Over the past ten years, he’s
written articles for Italian and international magazines and coauthored
more than ten books on a variety of computer topics.

xvii
Introduction
The self-service BI (business intelligence) movement in recent years
has vastly improved the capability of analysts in finance and front-line
businesses. The level of entry for Power BI is so low that everyone who
cares about data can start using it in a few days. Microsoft Power Platform
has further empowered everyone to build business applications and
automation solutions.

What Is This Book About?


This book empowers you to build better data solutions, respond faster to
stakeholder requests, and contribute to a better data culture in your areas
of choice. You learn the basics of building interactive reports using Power
BI, building applications using Power Apps, building process automation
flows using Power Automate, and finally, integrating all three tools to build
a comprehensive data-driven decision solution.

Who Is This Book For?


This book is for all Excel users with a good business understanding and
looking for ways to do things better and faster.
This book is for business analysts and reporting specialists who have
watched some YouTube videos on Power BI and are humble enough to
understand that a 30-minute video plus trial-and-error strategy has certain
limitations.

xix
Introduction

This book is for business and team leaders passionate about improving
decisions with available data but may be frustrated with the collaboration
process with some technical teams.
This book is also for university students willing to learn about one of
the most popular data platforms in 2023.

How Is This Book Structured?


The book is structured to address some of the most common business
challenges analysts face in their day-to-day job. It discusses business
challenges and the methods for solving them. In key chapters of the book,
you are given some mini-­hackathon-­style challenges as an effective way to
solidify the learning.
The book covers 11 chapters.
Chapter 1 quickly gets you started with building your first Power BI
report. Starting from a simple Power BI licensing guide to help you to
understand the common license rules and some limitations. You then
work on translating an existing Excel report into Power BI.
Chapter 2 introduces you to the three core components of Power BI:
Power Query, data models, and DAX. You use different components to
solve some of this chapter’s most common reporting challenges.
Chapter 3 helps you understand the best practices in collaboration and
automation. Power BI Service (cloud server) is another key advantage for
Power BI over its many competitors. This chapter focuses on how Power BI
Service can help you to facilitate collaboration and automation.
Chapter 4 provides a guide on visualizing data for self-service BI
solutions. This chapter starts with various visualization options and why
you should choose some charts over others. It introduces the concept of
data explanation vs. exploration and how to achieve both in Power BI. It
ends with some very practical report design concepts.

xx
Introduction

Chapter 5 provides an effective framework for collaboration between


multiple developers or teams of developers. This chapter starts with
governance. You learn about the utilization-driven approach to improve
build efficiency.
Chapter 6 provides an entry-level guide for data manipulation in SQL
databases for reporting purposes. You start with creating a cloud database
for practice purposes. You then learn to construct the most common SQL
queries.
Chapter 7 is a comprehensive guide on the SharePoint list for Power
Platform data storage. You start with creating and editing a SharePoint list.
You then focus on access and security considerations of the list. You also
learn about the different ways of connecting to Power BI.
Chapter 8 introduces creating simple applications with Power Apps.
You learn about Power Apps licensing arrangements. You first create
an app using the default Apps template. You then create an app from a
blank canvas.
Chapter 9 helps you to understand the fundamentals of Power Apps.
You learn about many important concepts, including variables and
delegation. You then improve the basic app using several techniques,
including the color palette, user interface features, dynamic calculation,
and more on user experience.
Chapter 10 helps you to understand the basics of cloud workflows.
You start with Power Automate licensing. You then learn about the basic
concepts of Cloud Flow. You build three common flows: email notification,
creating a backup, and creating approval workflows.
Chapter 11 introduces you to the Power Platform integrated solution
architecture. You learn how to build reporting, back-­end automation, and
front-end user applications into a single solution.

xxi
CHAPTER 1

Power BI First Report


Microsoft defines Power BI as follows: “Connect to and visualize any data
using the unified, scalable platform for self-service and enterprise business
intelligence (BI) that’s easy to use and helps you gain deeper data insight.”
Whereas this makes sense, no one else would describe Power BI that
way. Over the past seven years, I have worked with many new Power BI
users, including many from a technology background. Some of them see
Power BI as a glorified Excel, while others mainly focus on the visualization
aspect of the tool. While these are not wrong, they are just the tip of the
iceberg. As you can see in Figure 1-1, most people only see the reporting or
dashboard side of Power BI. People don’t see the back-end connections,
transformation, modeling, and cloud services. Arguably the power of
Power BI has more to do with what people don’t see than what they see.

© David Ding 2023 1


D. Ding, Transitioning to Microsoft Power Platform,
https://doi.org/10.1007/978-1-4842-9239-6_1
Chapter 1 Power BI First Report

Figure 1-1. Power BI process view

2
Chapter 1 Power BI First Report

The first three chapters tackle some practical challenges linked


to different business scenarios. Each challenge focuses on a specific
knowledge area, including data source connection, data transformation,
data model, various interactive visuals, sharing, and automation. You can
access the dataset and report files to follow the development steps.

Note Let’s start with a basic example and progress quickly into
more practical and in-depth scenarios. Check out Microsoft’s tour
if you want more time with the basics; visit https://docs.
microsoft.com/en-us/power-bi/fundamentals/desktop-
getting-started.

This first chapter focuses on developing the first report. Before you
get into the development, you first gain some knowledge about Power BI
subscriptions and costs.

Business Scenario
When it comes to real-world challenges, understanding the why is often
more important than knowing the how. This is also true for learning; it is
much easier to absorb the how if you understand the importance of the
content. This book revolves around Kim’s career development at AWM
Bicycle Company Limited.
AWM is a US-based bike manufacturing business that produces bikes,
bike parts, clothes, and accessories. The business faces strong overseas
competition, local labor shortages, and high operational costs. After
careful market analysis, leaders in AWM decided to consolidate its product
lines to produce fewer items that better meet the evolving needs of most
cyclists. Figure 1-2 shows AWM’s organizational structure.

3
Chapter 1 Power BI First Report

Figure 1-2. AWM organizational structure

Kim is a new university graduate with a degree in accounting. She is


passionate about data analytics and has the drive to make better decisions.
Kim joined AWM two months ago, reporting to Milo, the finance manager
under Claire’s CFO team. John and Claire were two financial partners that
reported to Milo.
After joining AWM for three months, Kim has learned about what the
company is doing and her role within the financial reporting team. Instead
of just giving her the administration tasks, Milo, the finance manager,
has decided to balance her exposure with small, ad hoc analysis projects.
Microsoft Excel is the only tool for data analysis; the visualization is done
in Excel and PowerPoint.

4
Chapter 1 Power BI First Report

Power BI Software Licensing


Software licensing and subscriptions are confusing but important aspects
of any tool. Understanding some basic rules help you to determine if the
tool is fit for purpose and cost-effective for your organization.
Kim told Milo that she taught herself how to use Microsoft Power BI
during her last semester at the university. To her pleasant surprise, Milo
showed a lot of interest in the tool. However, he was concerned about the
associated cost and asked her to investigate before proceeding.
Kim went to the Power BI pricing site at https://powerbi.microsoft.
com/en-us/pricing/ to read about the types of licenses and also the
difference between the license types. She summarized the situation in
Table 1-1.

Table 1-1. Power BI Licensing Summary (Sep-2022)


License Cost Use

Power BI Desktop Free Desktop can be used to develop


reports; this is also the full
version.
Power BI Pro US$10 per user per Pro is required for every user
month (60-day free trial) sharing and viewing reports.
Premium Per User US$20 per user per month Expensive options that unlock
(60-day free trial) additional features are not
required.
Premium Capacity $5,000 per capacity per More capacity features and
month (60-day free trial) sharing capabilities.

5
Chapter 1 Power BI First Report

In addition, she discovered different types of “workspaces” for sharing


the reports, as shown in Table 1-2.

Table 1-2. Power BI Workspaces


Workspace Type Required License Description

My Workspace No license required Reports can be published here only for


the publisher to see. It can’t be shared
without a Pro license.
Normal Workspace Power BI Pro Reports can be published here with
excellent sharing capabilities.
Premium Workspace Premium There are more capacity features and
sharing capabilities.

Generally speaking, this licensing arrangement makes it easy and low-­


cost at the start. The process for acquiring a new license is also very simple.
Premium capacity provides another option for organizations to cap their
spending.
The following are a few additional licensing rules to note.

• The professional license applies to people. There is


no “viewer license.” The Pro license allows developers
and viewers to access reports in workspaces. A
professional license is required to publish reports.
Except for personal workspace

• Premium capacity applies to workspaces. One


premium capacity can be assigned to multiple
workspaces. It gives all users access to read reports.
Workspaces with Premium Capacity also enable
premium functionalities. This includes the DevOps
function and paginated reports.

6
Chapter 1 Power BI First Report

Figure 1-3 shows the relationship between users, developers, and


Power BI workspaces.

Figure 1-3. User and developer workspaces licenses

Build Your First Power BI Report


Now that you understand the basics of Power BI licensing and cost, it is
time to build your first Power BI report.

Data and Requirements


In this task, let’s help Kim analyze the product sales data in Power BI. Milo
showed Kim the current Excel dashboard in Figure 1-4. He’s happy with
the layout, especially the interactive aspect of the data filters. He used this
for the monthly senior management team updates to show month-on-­
month sales performance. A copy of the report is in the file01 Excel report.
xlsx exercise file.

7
Chapter 1 Power BI First Report

The technology team generated the data sitting behind the chart. It
is in the file02 monthly product sales data.csv exercise file. The following
describes the monthly process.

1. Raw data is extracted from the data warehouse into


a CSV file and placed into the share-drive folder by
the 2nd working day of the month.

2. The finance team manually copies and pastes the


data into the raw data table in Excel.

3. The pivot table and charts are refreshed.

4. The updated file is saved into the same share-drive


folder by the fifth working day (WD5).

Figure 1-4. Excel report on sales revenue

8
Chapter 1 Power BI First Report

Install Power BI Desktop


Your first task is to install Power BI Desktop. There are two installation
options.

• Download from the Power BI site at https://powerbi.


microsoft.com/en-us/downloads/ and execute the
installation file.

• Download from Microsoft Store (recommended).

Microsoft Store method is preferred because it includes an auto-­


update feature. It is important to note that Microsoft rolls out new features,
improvements, and bug fixes monthly. Instead of downloading and
installing each month, it is easier to let Power BI update itself when a new
release is available.

Note It is possible to have two Power BI installed on the same


machine using the two different methods. This can result in a lot of
confusion. It is recommended to keep the installation by removing
both and reinstalling from the Microsoft Store.

Report Building
Replicating Excel reports is a good place to start with Power BI report.
There are two main reasons.

• Familiarity with data

• A separate report for data reconciliation purposes

Once Power BI is installed, you can build desktop reports. Figure 1-5
shows that connecting to some data is the first step.

9
Chapter 1 Power BI First Report

Figure 1-5. Connect to data from Power BI Desktop

You can then load the data, as shown in the following steps and
Figure 1-6.

1. Select Text/CSV.

2. Choose the file from the local folder.

3. Select Load.

Figure 1-6. Steps to connect to a CSV file

10
Chapter 1 Power BI First Report

Now that the data has been loaded into Power BI, note the different
functional areas of Power BI Desktop, as described next and illustrated in
Figure 1-7.

1. Report canvas is where visuals are created and


managed.

2. The ribbon displays common operations for reports


and visuals.

3. Chart options is the default visual selection panel.

4. Data fields can be dragged to the formatting pane.

5. Visual format is for data fields and custom


formatting.

6. Filters is the default area for adding filters to the


visuals and all pages.

7. Page is where you select or add pages.

8. Other views include navigating to report, data, and


model views.

Figure 1-7. Power BI Desktop function areas

11
Chapter 1 Power BI First Report

When replicating the Excel report, matching the visuals shown in


Figure 1-8 to Power BI visuals is a good idea.
The visuals include (1) text box, (2) slicers, (3) pie chart, (4) matrix, and
(5) line chart. They are added one by one into the dashboard.

Figure 1-8. Excel report visual in Power BI

Add a Text Box


A text box allows you to create a simple title. The following steps explain
how to do this, as shown in Figure 1-9.

1. Select Insert, then Text box in the ribbon.

2. Turn on Background and set the color to blue.

3. Add the Produce Sales Dashboard text and adjust


the text box size.

4. Select text and change Font Size to 28.


5. Change font style to Bold.

6. Change text alignment to Center.

7. Save the change to Replace Excel.

12
Chapter 1 Power BI First Report

Figure 1-9. Adding a text box

Add Slicers
You can add the slicers using the following steps, as illustrated in
Figure 1-10.

Tip Whenever you add a new element to the report canvas, you


should click a blank area so that no other elements are selected.

1. In Visualizations, choose the slicer.

2. Drag and drop Sales/Year into the data field of the


slicer visual.

3. From the Slicer drop-down, choose List.

13
Chapter 1 Power BI First Report

4. Repeat steps 1–3 for the


ProductCategoryName column.

5. Repeat steps 1–3 for the


ProductSubCategoryName column.

Figure 1-10. Adding a slicer

Tip The slicer drop-down box has a few options. The options


depend on the column type. You can try the different drop-down
options.

Add a Pie Chart


Add the pie chart. The following steps explain how to do it, as illustrated in
Figure 1-11.

1. Click a blank area of the canvas (apply this for all


future steps).

2. In Visualizations, choose the pie chart.

3. Drag and drop LineTotal into the pie chart values.

14
Chapter 1 Power BI First Report

4. Drag and drop ProductSubcategoryName into the


pie chart legend.

5. Select the format visual.

6. In the Label Content drop-down, choose Category,


Percentage of Total.

Figure 1-11. Adding a pie chart

Add a Matrix Table


The following steps add the matrix table, as illustrated in Figure 1-12.
1. In Visualizations, choose the matrix table.

2. Drag and drop LineTotal into matrix values.

3. Drag and drop ProductCategoryName into the


matrix columns.

4. Drag and drop SalesMonth into the matrix rows.

5. Select SalesMonth.

6. Change column format to yyyy-mm.

15
Chapter 1 Power BI First Report

Figure 1-12. Adding a matrix table

Add a Line Chart


The following steps explain how to add the line chart, as illustrated in
Figure 1-13.

1. In Visualizations, choose Line Chart.

2. Drag and drop LineTotal to the line chart Y-axis.

3. Drag and drop ProductCategoryName to the line


chart legend.

4. Drag and drop SalesMonth to the X-axis.

5. Adjust the position and size of the different visuals.

6. Apply the year filter to 2013 to see the 2013 view.

16
Chapter 1 Power BI First Report

Figure 1-13. Adding a line chart

Caution Power BI recognizes the SalesMonth column as a date


column. Sometimes Power BI may recognize the SalesMonth column
as a text column. This causes issues when you replicate the matrix
and line chart processes. Changing a column type is covered in the
Power Query session, so you can ignore the issues for now.

Congratulations, you have now replicated all elements from the Excel
report. One of the main strengths of Power BI over Excel is its dynamic and
interactive nature. You can click different sessions in the visual and see
how it causes other parts of the report to change.

Clean up the Report


Tidying up the report is a critical step when developing Power BI
reports. This may involve experimenting with different visuals, checking
unexpected interactions, and making adjustments.

17
Chapter 1 Power BI First Report

The following steps replace a line chart with a stacked column chart, as
illustrated in Figure 1-14.

1. Select the line chart and change the visual to a


stacked column chart.

2. Go to Format visual.

3. Switch on Total labels.

Figure 1-14. Change line chart to stacked column chart

There are three interaction options: Filter, Highlight, and No


interaction. If you pick a value in SalesMonth in the matrix table, the
pie chart and the stacked bar chart are highlighted. As you can see in
Figure 1-15, this interaction works well for the stacked bar chart but not so
well for the pie chart.

18
Chapter 1 Power BI First Report

Figure 1-15. The default Power BI interaction is Highlight

As illustrated in Figure 1-16, the following steps explain how to change


the interaction from a matrix table to a pie chart. In this case, you want
to filter the value in a pie chart. In this context, filter means that when a
month is chosen in the matrix table, the pie chart only shows the value and
breakdown for the month.

1. Select the matrix table.

2. Choose Format and select Edit interactions.

3. Change the interaction to Filter.

19
Chapter 1 Power BI First Report

Figure 1-16. Change interaction to Filter

Simplification is one important way of improving the dashboard.


The steps illustrated in Figure 1-17 remove unnecessary elements of the
dashboard to improve the overall experience.

1. Simplify the pie chart title.

2. Simplify the stack column chart title.

3. Remove the pie chart legend.

4. Remove the Y-axis.

5. Remove the X-axis title.

6. Add borders to the visuals.

20
Chapter 1 Power BI First Report

Figure 1-17. Areas of simplification

These simple changes make the report look more professional. The
change can be seen in Figure 1-18.

Figure 1-18. Simplified report

21
Chapter 1 Power BI First Report

Conclusion
Congratulations on developing your first Power BI report! In this chapter,
you learned about two main knowledge areas in Power BI.
• Power BI subscriptions and the associated costs

• How to build a Power BI report

You may find this first report-building experience to be very intuitive.


This is because it only uses the most common features of Power BI, which
have been optimized, and much of the complexity is hidden from the
report developers.
Many new developers stay at this entry level for a long time because
gaining a good understanding of Power BI takes some deliberate effort. In
the next chapter, you learn about the core components of Power BI.

22
CHAPTER 2

Power BI Core
Components
This chapter uncovers the three key components of Power BI Desktop:
Power Query, data models, and Data Analysis Express (DAX). Each
component performs a critical aspect in the data analysis. Many reports
developer overly focus on DAX and neglects the importance of Power
Query and data models. This often results in overcomplicated and
unpredictable DAX. This chapter explores the following.

• Power Query for loading and transforming data tables

• Data models for creating relationships between


data tables
• DAX to create measures, columns, and tables in
the report

Build a Report with Power Query


Prior to the introduction of Power Query, data automation in Excel was
typically done through macros. Macros are recorded in the Visual Basic
for Applications (VBA) programming language. Macros store a set of
ordered VBA instructions to perform the different tasks required for data
automation.

© David Ding 2023 23


D. Ding, Transitioning to Microsoft Power Platform,
https://doi.org/10.1007/978-1-4842-9239-6_2
Chapter 2 Power BI Core Components

Compared to VBA, Power Query M is much more intuitive and


user-friendly. It also provides a set of very practical data transformation
functions to help simplifying common data transformation tasks. The
Power Query M language was first introduced in Excel 2010. It is a more
data centric style of programming language. Power Query was packaged
into Power BI to import, transform and combine datasets. Power Query is
one of the main reasons why Power BI is ahead of many of its competitors.
In this session, you learn how Power Query can automate complex
data processes.

Business Scenario
After the initial success of the Sales Dashboard migration in Power BI. Milo
has asked Kim to push the report one step further by including the product
cost data. This dataset is useful for understanding both the cost and margin
calculations.
The product cost data is in the file03productcostdata.csv exercise file.

Data Processing Automation


Before you continue with the new file, let’s take a step back and check out
the data refresh process. If you open the last file from Chapter 1 and click
the refresh button in Figure 2-1, the dataset is reloaded into Power BI.

Figure 2-1. Refresh data in Power BI

24
Chapter 2 Power BI Core Components

The following steps, as shown in Figure 2-2, provide information to


help you understand the data loading process.

1. Right-click the Sales table in Fields.

2. Select Edit query.

Figure 2-2. Edit query

This action takes you to the Power Query Editor, as shown in


Figure 2-3. There are a few different function areas in the editor.

1. The ribbon displays common tasks.

2. Queries lists stored queries.


3. Table preview displays the first 1,000 records in
the query.

4. APPLIED STEPS query executes step by step


following the function order.

5. The formula bar is the Power Query function


executed in each step.

25
Chapter 2 Power BI Core Components

Figure 2-3. Power Query Editor function areas

Figure 2-4 shows that there are three transformation steps. If you click
through each step, you can see the formula.

1. Source = Csv.Document(File.Contents(“E:\
folder…\monthly product sales data.
csv”),[Delimiter=“,”, Columns=12, Encoding=65001,
QuoteStyle=QuoteStyle.None])

2. Promoted Headers = Table.


PromoteHeaders(Source, [PromoteAllScalars=true])

3. Changed Type = Table.


TransformColumnTypes(#“Promoted
Headers”,{{“OrderDate”, type date}, {“LineTotal”, type
number}, {“UnitPrice”, type number}, {“OrderQty”,
Int64.Type}})

26
Chapter 2 Power BI Core Components

Figure 2-4. Power Query transformation steps

While the formula may look daunting initially, it is easy to understand.


By focusing on the function names, you know that the steps are loading a
CSV file, using the first row as the header, and changing the column type.

Create a New Query


Now that you have a basic understanding of Power Query, create a new
query. The following steps, as shown in Figure 2-5, explain how to connect
to the product data.

1. In the Power Query Editor, select New Source →


Text/CSV.

2. Choose the product cost data file.

Figure 2-5. Create a new query

27
Another random document with
no related content on Scribd:
demasiado grandes. En los Reali el tener un pie más grande que
otro: «Aveva nome Berta del gran piè, perchè ella avea maggiore
un poco un piè che l'altro, e quello era il pié destro» (cap. I).
[251] La Gran Conquista de Ultramar, ed. de Gayangos, pp. 175-
178.
[252] Sobre las fuentes de este famoso libro, cuya primera
edición se remonta á 1491, es magistral y definitivo el trabajo de
Rajna, Ricerche intorno ai Reali di Francia (Bolonia, 1872, en la
Collezione di Opere inedite o rare dei primi tre secoli della lingua).
En la misma colección puede leerse el texto publicado por un
discípulo de Rajna: I Reali di Francia, di Andrea da Barberino,
testo critico per cura di Giuseppe Vandelli (Bolonia, 1902).
[253] Romania, julio de 1873, p. 363.
[254] No viejo ni caduco, pero sí pequeño y deforme era ya
Pipino en el poema franco-itálico: «Por que eo sui petit e
desformé». «Petit homo est, inais grosso e quarré».
[255] Aunque el desatino de hacer enamorada á Berta pertenece,
con todas sus consecuencias, á Antonio de Eslava, debe
advertirse que ya en el poema bilingüe de la Biblioteca Marciana,
seguido en esta parte por el compilador de I Reali, era Berta la
que proponía la sustitución y por un motivo verdaderamente
absurdo. Llegando á París fatigada del viaje, ruega á la hija del
conde de Maganza Belencer que la reemplace en el lecho de
Pipino durante la primera noche de bodas, pero fingiéndose
enferma para que el rey no llegue á tocarla. Con fingirlo ella
misma se hubiera ahorrado el engaño de la falsa amiga. En la
Crónica rimada de Felipe Mouskes, que escribía hacia 1243, la
reina alega un motivo obsceno para hacerse sustituir por su
sierva Alista. En el poema de Adenès, Berta consiente en la
superchería, porque su sierva Margista (el ama de la Crónica
General) la ha hecho creer que el Rey quiere matarla en la
primera noche de bodas.
[256] ¡Cuán lejano está esto de la delicadeza y elevación moral
del texto de Adenès! en que Berta, que había hecho voto de no
revelar su nombre más que cuando viese en peligro su castidad,
exclama, perseguida por el rey en el bosque de Mans: «Soy reina
de Francia, mujer del rey Pipino, hija del rey Flores y de la reina
Blancaflor, y os prohibo, en nombre de Dios que gobierna el
mundo, hacer ninguna cosa que pueda deshonrarme: antes
preferiría ser muerta, y Dios venga en mi ayuda».
[257] Vid. G. París, Histoire poètique de Charlemagne, pp. 170-
409; Guessard, en la Bibliothèque de l'École des Chartes, 1856,
pág. 393 y siguientes, y muy especialmente Rajna, Ricerche
intorno ai Reali di Francia, pág. 253 y ss.
[258] Le prime imprese del conte Orlando di Messer Lodovico
Dolce, da lui composte in ottava rima, con argomenti ed allegorie.
All'Illustriss. et Eccellentiss. Signor Francesco Maria della Rovere
Prencipe d'Urbino. Vinegia, appresso Gabriel Giolito de Ferrari,
1572, 4.º.
[259] El nascimiento y primeras Empressas del conde Orlando.
Tradvzidas por Pero López Enriquez de Calatayud, Regidor de
Valladolid. Valladolid, por Diego Fernández de Córdoba y Oviedo.
Sin año, pero la fecha 1594 se infiere del privilegio.
[260] Impresa en la Parte 19.ª de sus Comedias y en el tomo XIII
de la edición académica.
[261] Historia de la linda Melosina de Juan de Arras.
Colofón: Fenesce la ystoria de Melosina empremida en Tholosa
por los honorables e discretos maestros Juan paris e Estevan
Clebat alemanes que con grand diligencia la hizieron pasar de
frances en Castellano. E despues de muy emendada la
mandaron imprimir. En el año del Señor de mill e quatrocientos e
ochenta e nueue años a XIII dias del mes de julio.
Hay otras ediciones de Valencia, 1512, y Sevilla, 1526.
[262] No conozco más que por referencias estos trabajos de
Garnett, ni aun puedo recordar á punto fijo dónde los he visto
citados. Pero como no gusto de engalanarme con plumas ajenas,
y se trata de un descubrimiento de alguna importancia, he creído
justo indicar que un inglés había notado antes que yo la analogía
entre la novela de Eslava y La Tempestad. Los comentadores de
Shakespeare que tengo á mano no señalan más fuentes que una
relación de viajes y naufragios, impresa en 1610 con el título de
The Discovery of the Bermudas or Devil's Island, y una comedia
alemana del notario de Nuremberg Jacobo Ayrer, La hermosa
Sidea (Die Schöne Sidea), fundada al parecer en otra inglesa,
que pudo conocer Shakespeare, y de la cual supone Tieck que el
gran poeta tomó la idea de la conexión que establece entre
Próspero y Alonso, Miranda y Fernando. Pero, según Gervinus, á
esto ó poco más se reduce la semejanza entre ambas obras. Vid.
Shakespeare Commentaries by Dr. G. Gervinus... Translated... by
F. E. Bunnèt, Londres, 1883, pág. 788.
Tampoco Ulrici acepta la conjetura de Tieck, y aun sin tener
noticia de las Noches de Invierno, se inclina á admitir la hipótesis
de una novela española antigua que pudo servir de fuente común
á Shakespeare y al autor de una antigua balada, descubierta por
Collier, que la publicó en la Quarterly Review, 1840. Siento no
conocer esta balada.
Vid. Shakespeare's Dramatic Art, History and character of
Shakespeare Plays. By Dr. Hermann Ulrici. Translated from the
third edition of the German... by L. Dora Schmitz. Londres, 1876
Tom. II, pp. 38-39, nota.
[263] Vid. Perott (Joseph de), The probable source of the plot of
Shakespeare's «Tempest». (En las Publications of the Clark
University Library Worcester, Mass. Octubre de 1905).
[264] No ha faltado quien sospechase, pero esto parece ya
demasiada sutileza, que este mismo título de una de las últimas
comedias de Shakespeare (Winter's tale) era reminiscencia de
las Noches de Eslava.
[265] No he podido encontrar un rarísimo pliego suelto gótico que
describe Salvá (n. 1.179 de su Catálogo) y contenía un cuento en
prosa, Como vn rustico labrador ēgaño a vnos mercaderes,
cuatro hojas, sin lugar ni año, hacia 1510, según el parecer de
aquel bibliógrafo. Sir Thomas Grenville tuvo otra edición del
mismo pliego con el título algo diverso, Como vn rustico labrador
astucioso con cōsejo de su mujer engaño a vnos mercaderes.
Supongo que hoy parará en el Museo Británico.
[266] Es el 4.º del Novellino. Notó antes que nadie esta
semejanza Morel-Fatio.
«Fra Girolamo da Spoleto con un osso di corpo morto fa credere
al popolo Sorrentino sia il braccio di Santo Luca: il compagno gli
dà contra: lui prega Iddio che ne dimostri miracolo: il compagno
finge cascar morto, ed esso oramai lo ritorna in vita; e per li doppi
miracoli raduna assai moneta, diventane prelato, e col compagno
poltroneggia».
(Il Novellino di Masuccio Salernitano, ed. de Settembrini, p. 53 y
ss.)
[267] Esta imitación fué ya indicada en la History of fiction de
Dunlop (trad. alemana de Liebrecht, p. 268). Es la novela 41 de
Masuccio (p. 425). «Due cavalieri fiorentini se innamorano de due
sorelle fiorentine, son necessitati ritornarsi in Francia. Una delle
quelle con una sentenziosa intramessa de un falso diamante fa
tutti doi ritornare in Fiorenza, e con una strana maniera godono a
fine di loro amore».
De éstas y otras imitaciones trataré en sus lugares respectivos.
Aquí basta indicarlas.
[268] Véase el primer tomo de la presente obra, pág, CCCCLVIII.
[269] Las ediciones más antiguas del Galateo que citan los
bibliógrafos son: la de Zaragoza, 1593; la de Barcelona 1595, y la
de Madrid, 1599; pero debe de haberlas algo anteriores, puesto
que la dedicatoria está firmada á 10 de enero de 1582. La más
antigua de las que he manejado es la siguiente:
—Galateo Español. Agora de nuevo corregido y emendado. Autor
Lucas Gracian Dantisco criado de su Magestad. Impresso en
Valencia, en casa de Pedro Patricio Mey, 1601. A costa de
Balthasar Simon mercader de libros.
8.º, 239 pp. (por errata 293).
Aprobación del Dr. Pedro Juan Asensio, por comisión del
patriarca D. Juan de Ribera (20 de marzo de 1601).
«Aviendo visto en el discurso de mi vida, por esperiencia todas
las reglas de este libro, me parecio aprovecharme de las más,
que para el tiempo de la juventud pueden ser de consideracion,
traduziendolas del Galateo Italiano, y añadiendo al proposito
otros Cuentos y cosas que yo he visto y oydo; los quales serviran
de sainete y halago, para pasar sin mal sabor las pildoras de una
amable reprehension que este libro haze. Que aunque va
embuelto en cuentos y donayres, no dexara de aprovechar a
quien tuviere necessidad de alguno destos avisos, si ya no
tuviere tan amarga la boca, y estragado el gusto, que nada le
parezca bien...».
Sonetos laudatorios del Licenciado Gaspar de Morales, de Lope
de Vega y de un anónimo.
Todo el libro está lleno de cuentecillos, unos traducidos del
italiano y otros originales de Gracián Dantisco.
—Galateo Español. Agora nueuamente impresso, y emendado.
Avtor Lucas Gracian Dantisco, criado de su Magestad. Y de
nueuo va añadido el destierro de la ignorancia, que es
Quaternario de auisos conuenientes a este nuestro Galateo. Y la
vida de Lazarillo de Tormes, castigado. Con licencia. En
Valladolid. Por Luis Sanchez. Año de 1603. A costa de Miguel
Martinez.
8.º, 6 hs. prls. y 295 pp. dobles.
Pág. 171. «Destierro de ignorancia. Nueuamente compuesto y
sacado a luz en lengua Italiana por Horacio Riminaldo Boloñés. Y
agora traduzido de lengua Italiana en Castellana. Con licencia.
En Valladolid. Por Luys Sanchez. Año M.DCIII.
«Es obra muy prouechosa y de gran curiosidad y artificio: porque
cifrandose todo lo que en ella se contiene debaxo del numero de
quatro, discurre con él por todo el Abecedario, començando
primeramente por cosas que tienen por principio la letra A desta
suerte...».
Fol. 217. Lazarillo de Tormes, castigado. Agora nueuamente
impresso, y emendado.
Hay reimpresiones de 1632, 1637, 1664, 1722, 1728, 1746, 1769
y otras varias.
[270] Pág. 151 de la ed. de Valencia, 1601.
[271] PP. 154-179.
Esta novelita llegó á ser tan popular, que todavía se hizo de ella
una edición de cordel á mediados del siglo xviii.
Historia del Gran Soldan con los amores de la linda Axa y
Principe de Napoles. Cordoba, Juan Rodriguez de la Torre. Sin
año.
Modernamente la refundió Trueba en uno de sus Cuentos
Populares que lleva por título El Principe Desmemoriado.
[272] PP. 179-180.
[273] La extensión que ha tomado el presente capítulo me obliga
á diferir para el volumen siguiente, que será el tercero de estos
Orígenes de la novela, el estudio de las novelas de
costumbres y de las novelas dramáticas anteriores á Cervantes.
En él se encontrarán también las noticias críticas y bibliográficas
de algunos diálogos satíricos afines á la novela, cuyo texto va
incluido en el presente volumen.
CARCEL DE AMOR

DE

DIEGO DE SAN PEDRO

EL SIGUIENTE TRACTADO FUÉ


HECHO A
PEDIMENTO
DEL SEÑOR DON DIEGO
HERNANDES:
ALCAYDE DE LOS DONZELES Y
DE OTROS
CAUALLEROS CORTESANOS:
LLÁMASE «CARCEL DE
AMOR».
CONPÚSOLO SAN PEDRO

COMIENÇA EL PROLOGO ASSI

Muy virtuoso señor:


Aunque me falta sofrimiento para
callar, no me fallesce
conoscimiento para ver quanto
me estaria meior preciarme de lo
que callase que arepentirme de lo
que dixiese; y puesto que assi lo
conozca, avnque veo la verdad
sigo la opinion, y como hago lo
peor nunca quedo sin castigo,
porque si con rudeza yerro con
verguença pago. Verdad es que
en la obra presente no tengo
tanto cargo pues me puse en ella
más por necesidad de obedescer
que con voluntad de escreuir.
Porque de vuestra merced me fue
dicho que deuia hazer alguna
obra del estilo de vna oracion que
enbié a la señora doña Marina
Manuel porque le parecia menos
malo que el que puse en otro
tratado que vio mio. Assi que por
conplir su mandamiento pense
hacerla, auiendo por meior errar
en el dezir, que en el
desobedecer. Y tambien acordé
endereçarla á vuestra merced,
porque la fauorezca como señor y
la emiende como discreto. Como
quiera que primero que me
determinase, estuue en grandes
dubdas. Vista vuestra discrecion
temia, mirada vuestra virtud
osaua. En lo uno hallaua el
miedo, y en lo otro buscaua la
seguridad, y en fin escogí lo más
dañoso para mi verguença, y lo
más provechoso para lo que
deuia.
Podré ser reprehendido, si en lo
que agora escriuo, tornare á dezir
algunas razones, de las que en
otras cosas he dicho. De lo qual
suplico á vuestra merced me
salue; porque como he hecho otra
escritura de la calidad de esta, no
es de marauillar que la memoria
desfallesca. Y si tal se hallare, por
cierto más culpa tiene en ello mi
oluido que mi querer.
Sin dubda, Señor, considerado
esto y otras cosas que en lo que
escriuo se pueden hallar, yo
estaua determinado de cesar ya
en el metro y en la prosa, por
librar mi rudeza de juyzios, y mi
espíritu de trabaios. Y paresce
quanto más pienso hazerlo, que
se me ofrecen más cosas para no
poder conplirlo. Suplico á vuestra
merced antes que condene mi
falta, juzgue mi voluntad, porque
reciba el pago no segund mi
razon, mas segund mi deseo.

COMIENÇA LA OBRA
Despues de hecha la guerra del
año pasado, viniendo á tener el
inuierno á mi pobre reposo,
pasando vna mañana, quando ya
el sol queria esclarecer la tierra,
por vnos valles hondos y escuros,
que se hazen en la Sierra
Morena, vi salir á mi encuentro
por entre unos robredales do mi
camino se hazia, vn cauallero assi
feroz de presencia como
espantoso de vista, cubierto todo
de cabello á manera de saluaie.
Leuaua en la mano ysquierda vn
escudo de azero muy fuerte y en
la derecha una ymagen femenil,
entallada en vna piedra muy
clara, la qual era de tan estrema
hermosura, que me turbaua la
vista; salian della diuersos rayos
de fuego que leuaua encendido el
cuerpo de vn onbre quel cauallero
forciblemente leuaua tra si. El
qual con un lastimado gemido de
rato en rato dezia: en mi fe se
sufre todo.
Y como empareió comigo, dixome
con mortal angustia: caminante,
por Dios te pido que me sigas y
me ayudes en tan grand cuyta. Yo
que en aquella sazon tenia más
causa para temor que razon para
responder; puestos los oios en la
estraña vision estoue quedo,
trastornando en el coraçon
diuersas consideraciones. Dexar
el camino que leuaua pareciame
desuario, no hazer el ruego de
aquel que assi padecia
figurauaseme inumanidad. En
siguille auia peligro, y en dexalle
flaqueza. Con la turbacion no
sabia escojer lo meior. Pero ya
que el espanto dexó mi alteracion
en algund sosiego, vi quanto era
más obligado á la virtud que á la
vida: y empachado de mi mesmo
por la dubda en que estuue, seguí
la via de aquel que quiso
ayudarse de mi. Y como apresuré
mi andar, sin mucha tardança
alcancé a él y al que la fuerça le
hazia, y assi seguimos todos tres
por vnas partes no menos
trabaiosas de andar, que solas de
plazer y de gente, y como el
ruego del forçado fué causa que
lo siguiese, para acometer al que
lo leuaua faltabame apareio y
para rogalle merescimiento, de
manera que me fallecia conseio.
Y despues que reboluí el
pensamiento en muchos
acuerdos, tomé por el meior
ponerle en alguna plática, porque
como él me respondiese, así yo
determinase. Y con este acuerdo
supliquéle con la mayor cortesia
que pude, me quisiese dezir quien
era, á lo qual assi me respondió:
Caminante, segund mi natural
condicion, ninguna respuesta
quisiera darte porque mi oficio
mas es para secutar mal que para
responder bien; pero como
siempre me crié entre onbres de
buena criança, vsaré contigo de la
gentileza que aprendi y no de la
braueza de mi natural. Tú sabras
pues lo quieres saber. Yo soy
principal oficial en la casa de
amor, llamanme por nombre
Deseo. Con la fortaleza deste
escudo defiendo las esperanças,
y con la hermosura desta ymagen
causo las aficiones y con ellas
quemo las vidas, como puedes
ver en este preso que lieuo á la
carcel de Amor donde con solo
morir se espera librar.
Quando estas cosas el
atormentator cauallero me yba
diziendo, sobiamos vna sierra de
tanta altura, que á mas andar mi
fuerça desfallecia: y ya que con
mucho trabaio llegamos á lo alto
della, acabó su respuesta. Y
como vido que en más pláticas
quería ponelle yo que començaua
á dalle gracias por la merced
recebida, supitamente
desaparecio de mi presencia. Y
como esto pasó a tienpo que la
noche venia, ningund tino pude
tomar para saber donde guió: y
como la escuridad y la poca
sabiduría de la tierra me fuesen
contrarias, tomé por propio
conseio no mudarme de aquel
lugar. Allí comence á maldezir mi
ventura, allí desesperaua de toda
esperança, allí esperaua mi
perdimiento, allí en medio de mi
tribulacion nunca me pesó de lo
hecho; porque es meior perder
haziendo virtud, que ganar
dexandola de hazer. Y assí
estuue toda la noche en tristes y
trabaiosas contemplaciones: y
quando ya la lumbre del día
descubrio los canpos, vi cerca de
mí, en lo mas alto de la sierra,
vna torre de altura tan grande,
que me parecía llegar al cielo; era
hecha por tal artificio, que de la
estrañeza della comence á
marauillarme. Y puesto al pie,
avnque el tienpo se me ofrecia
más para temer que para notar,
miré la nouedad de su lauor y de
su edificio.
El cimiento sobre que estaua
fundada, era vna piedra tan fuerte
de su condicion y tan clara de su
natural, qual nunca otra tal iamás
auia visto: sobre la qual estauan
firmados quatro pilares de vn
marmol morado muy hermoso de
mirar. Eran en tanta manera altos,
que me espantaua como se
podian sostener. Estaua encima
dellos labrada vna torre de tres
esquinas, la más fuerte que se
puede contemplar. Tenia en cada
esquina, en lo alto della, vna
ymagen de nuestra umana
hechura, de metal, pintada cada
vna de su color; la vna de
leonado, y la otra de negro, y la
otra de pardillo. Tenia cada vna
dellas vna cadena en la mano
asida con mucha fuerza. Ví más
encima de la torre vn chapitel
sobrél qual estaua vn aguila que
tenia el pico y las alas llenas de
claridad de vnos rayos de lumbre
que por dentro de la torre salían á
ella. Oya dos velas que nunca vn
solo punto dexauan de velar. Yo
que de tales cosas iustamente me
marauillaua, ni sabia dellas qué
pensase, ni de mí qué hiziese; y
estando conmigo en grandes
dubdas y confusion, ví trauada
con los mármoles dichos vn
escalera que llegaua á la puerta
de la torre, la qual tenia la entrada
tan escura, que parescia la sobida
della á ningund onbre posible.
Pero ya deliberado quise antes
perderme por sobir, que saluarme
por estar, y forçada mi fortuna,
comencé la sobida. Y á tres
pasos del escalera hallé vna
puerta de hierro, de lo que me
certificó más el tiento de las
manos que la lumbre de la vista,
segund las tinieblas do estaua.
Allegado pues á la puerta, hallé
enella vn portero, al qual pedí
licencia para la entrada, y
respondiome que lo hacia, pero
que me conuenia dexar las armas
primero que entrase; y como le
daua las que leuaua, segund
costumbre de caminantes,
díxome:
Amigo, bien paresce que de la
usança desta casa sabes poco.
Las armas que te pido, y te
conuiene dexar, son aquellas con
que el coraçon se suele defender
de tristeza, assí como Descanso,
y Esperança, y Contentamiento,
porque con tales condiciones
ninguno pudo gozar de la
demanda que pides.
Pues sabida su intencion, sin
detenerme en echar iuyzios sobre
demanda tan nueua, respondile
que yo venía sin aquellas armas,
y que dello le dava seguridad.
Pues como dello fue cierto, abrió
la puerta: y con mucho trabajo y
desatino llegué ya á lo alto de la
torre donde hallé otro guardador
que me hizo las preguntas del
primero, y despues que supo de
mí lo que el otro, diome lugar á
que entrase. Y llegado al
aposentamiento de la casa, ví en
medio della vna silla de fuego en
la qual estaua asentado aquel
cuyo ruego de mi perdicion fue
causa. Pero como allí con la
turbacion descargaua con los
oios, la lengua más entendía en
mirar marauillas que en hazer
preguntas, y como la vista no
estaua despacio, ví que las tres
cadenas de las ymágines que
estauan en lo alto de la torre
tenían atado aquel triste que
sienpre se quemaua y nunca se
acabaua de quemar. Noté más,
que dos dueñas lastimeras con
rostros llorosos y tristes le seruían
y adornauan, poniendole con
crueça en la cabeza vna corona
de vnas puntas de hierro sin
ninguna piedad, que le
traspasauan todo el celebro. Y
después desto miré que vn negro
vestido de color amarilla venia
diuersas vezes á echalle una
visarma, y ví que le recebía los
golpes en vn escudo que
supitamente le salia de la cabeça
y le cobria hasta los pies. Ví más,
que quando le truxeron de comer
le pusieron vna mesa negra, e
tres seruidores mucho diligentes,
los quales le dauan con graue
sentimiento de comer. Y bueltos
los oios al vn lado de la mesa, ví
vn vieio anciano sentado en vna
silla, echada la cabeça sobre vna
mano en manera de onbre
cuidoso, y ninguna destas cosas
pudiera ver segund la escuridad
de la torre, sino fuera por vn claro
resplandor que le salía al preso
del coraçon, que la esclarecía
toda. El qual como me vió atónito
de ver cosas de tales misterios,
viendo como estaua en tienpo de
poder pagarme con su habla lo
poco que me deuia, por darme
algund descanso, mezclando las
razones discretas con las
lágrimas piadosas, començo en
esta manera á dezirme:

EL PRESO AL AUCTOR
Alguna parte del coraçon quisiera
tener libre de sentimiento por
dolerme de tí, segund yo deuiera
y tú merecías. Pero ya tu vees en
mi tribulacion, que no tengo poder
para sentir otro mal sino el mio.
Pidote que tomes por satisfacion
no lo que hago, mas lo que
deseo. Tu venida aquí yo la
causé. El que viste traer preso yo
soy, y con la turbacion que tienes,
no as podido conoscerme. Torna
en tí tu reposo, sosiega tu iuyzio
porque estés atento á lo que te
quiero dezir. Tu venida fué por
remediarme, mi habla será por
darte consuelo puesto que yo dél
sepa poco. Quien yo soy quiero
dezirte; de los misterios que vees
quiero informarte. La causa de mi
prision quiero que sepas, que me
delibres quiero pedirte si por bien
lo touieres. Tú sabras que yo soy
Leriano, hijo del duque Guersio,
que Dios perdone, y de la
duquesa Coleria. Mi naturaleza,
es este reyno do estás, llamado
Macedonia. Ordenó mi ventura
que me enamorase de Laureola
hija del rey Gaulo que agora
reyna, pensamiento que yo
deviera antes huyr que buscar;
pero como los primeros
mouimientos no se puedan en los
onbres escusar, en lugar de
desuiallos con la razon,
confirmelos con la voluntad, y assi
de amor me vencí, que me truxo á
esta tu casa la qual se llama
Carcel de Amor. Y como nunca
perdona, viendo desplegadas las
velas de mi deseo, púsome en el
estado que vees, y porque
puedas notar meior su
fundamiento y todo lo que has
visto, deues saber que aquella
piedra sobre quien la prision está
fundada, es mi Fé que determinó
de sofrir el dolor de su pena por
bien de su mal. Los quatro pilares
que asientan sobre ella son mi
Entendimiento y mi Razon, y mi
Memoria, y mi Voluntad. Los
quales mandó Amor parescer en
su presencia antes que me
sentenciase; y por hazer de mi
iusta iusticia, preguntó por si á
cada vno si consentía que me
prendiesen, porque si alguno no
consentiese me absoluería de la
pena. Á lo qual respondieron
todos en esta manera. Dixo el
Entendimiento: yo consiento al
mal de la pena por el bien de la
causa, de cuya razon es mi voto
que se prenda. Dixo la Raçon: yo
no solamente do consentimiento
en la prision, más ordeno que
muera; que meior le estará la
dichosa muerte que la
desesperada vida, segund por
quien se ha de sofrir. Dixo la
Memoria: pues el Entendimiento y
la Razon consienten, porque sin
morir no pueda ser libre, yo
prometo de nunca oluidar. Dixo la
Voluntad: pues que assi es, yo
quiero ser llaue de su prision y
determino de sienpre querer.
Pues oyendo Amor que quien me
auia de saluar me condenaua, dió
como iusto esta sentencia cruel
contra mí. Las tres ymágines que
viste encima de la torre cubiertas
cada vna de su color, de leonado
y negro y pardillo, la vna es
Tristeza, y la otra Congoxa, y la
otra Trabaio. Las cadenas que
tenian en las manos son sus
fuerças, con las quales tiene
atado el coraçon porque ningund
descanso pueda recebir. La
claridad grande que tenia en el
pico y alas el aguila que viste
sobre el chapitel, es mi
Pensamiento, del qual sale tan
clara luz por quien está en él, que
basta para esclarecer las tinieblas
deste triste carcel, y es tanta su
fuerça que para llegar al aguila
ningund impedimento le haze lo
grueso del muro, assi que andan
él y ella en vna conpañía, porque
son las dos cosas que más alto
suben, de cuya causa está mi
prision en la mayor alteza de la
tierra. Las dos velas que oyes
velar con tal recaudo, son
Desdicha y Desamor. Traen tal
auiso porque ninguna esperança
me pueda entrar con remedio. El
escalera obscura por do sobiste
es el Angustia con que sobí
donde me vees. El primero
portero que hallaste, es el Deseo,
el qual á todas tristezas abre la
puerta, y por esso te dixo que
dexases las armas de plazer si
por caso las trayas. El otro que
acá en la torre hallaste, es el
Tormento que aquí me traxo, el
qual sigue en el cargo que tiene la
condicion del primero, porque
está de su mano. La silla de fuego
en que asentado me vees, es mi
iusta Aficion cuyas llamas
siempre arden en mis entrañas.
Las dos dueñas que me dan
como notas corona de martyrio,
se llaman la vna Ansia y la otra
Passion, y satisfaçen á mi Fé con
el galardon presente. El vieio que
vees asentado, que tan cargado
pensamiento representa, es el
graue Cuydado que iunto con los
otros males pone amenazas á la
vida. El negro de vestiduras
amarillas que se trabaia por
quitarme la vida, se llama
Desesperar; el escudo que me
sale de la cabeça con que de sus
golpes me defiendo, es mi Iuyzio,
el qual viendo que vo con
desesperacion á matarme,
dizeme que no lo haga, porque
visto lo que merece Laureola
antes deuo desear larga vida por
padecer, que la muerte para
acabar. La mesa negra que para
comer me ponen, es la Firmeça
con que como, y pienso y
duermo, en la qual sienpre estan
los maniares tristes de mis
contenplaciones. Los tres solicitos
seruidores que me seruian, son
llamados Mal y Pena y Dolor. El
vno trae la cuyta con que coma y
el otro trae la desesperança en
que viene el maniar, y el otro trae
la tribulacion y con ella, para que
beua, trae el agua del coraçon á
los oios, y de los oios á la boca.
Si te parece que soy bien seruido
tú lo iuzga; si remedio he
menester tú lo vees; ruegote
mucho, pues en esta tierra eres
venido, que tú me lo busques y te
duelas de mí. No te pido otro bien
sino que sepa de tí Laureola, quál
me viste, y si por ventura te
quisieres dello escusar porque me
vees en tienpo que me falta
sentido para que te lo agradezca,
no te escuses, que mayor virtud
es redemir los atribulados que
sostener los prósperos. Assi sean
tus obras que ni tú te quexes de ti
por lo que no heziste, ni yo por lo
que pudieras hazer.

RESPUESTA DEL AUCTOR Á


LERIANO
En tus palabras, señor, as
mostrado que pudo Amor prender
tu libertad y no tu virtud, lo qual se
prueua porque segund te veo
deues tener mas gana de morir

Вам также может понравиться