M01 PowerBI Desktop
M01 PowerBI Desktop
3rd wave
End user BI
Everyone
2nd wave
Self-service BI
Analyst to end user
1st wave
Technical BI
IT to end user
Turning data into business insights is challenging
Right data for the right Different roles have different needs and business
users at the right time users need the latest operational data
Gartner’s 2020 Magic Quadrant
Gartner
recognizes
Microsoft as a
• High Value
leader in
Analytics and • Comprehensive analytics
BI platforms solution
for 11 • Centralized management
consecutive • Global scale
years. Why • Security, governance,
have the and compliance
customers
chosen Power
BI?
Power BI
Author Share and collaborate Large scale deployments Share and collaborate App dev
</>
Power BI Power BI Power BI Power BI Power BI
Desktop service Premium Report Server Embedded
Free data analysis Cloud-based modern Dedicated capacity for On-premises report Visual analytics
and report authoring increased performance server (updated 3x embedded in your
tool business analytics per year) applications
solution
Power BI Overview
On-premises data
e.g. Analysis Services Live dashboards
Organizational content
packs
Corporate data sources or external Visualizations
data services
Azure services
Azure SQL, Stream Analytics… Reports
Excel files
Workbook data / data models
01001
Power BI Desktop files 10101
Datasets
Data from files, databases, Azure,
and other sources Data refresh
Power BI Desktop Power BI REST APIs
00010110
0110001
Prepare Explore Report Share
Create Power BI Content
What is Power BI Desktop ?
A free downloadable
32/64 bit desktop
Does not depend on
application optimized
Microsoft Office
for the Power BI
Service
Dedicated BI workflow:
Combines the power Specializing in
of Power Query, Power Interactive
Pivot and Power View Visualization and
Analysis
Effortlessly publish
Main output:
interactive visual
Interactive Reports
reports to Power BI
and Data Models
users
Support: Monthly
updates
Power BI Desktop Workflow
Prepare
Explore
Report
Share &
Collaborate
Questions?
Knowledge Check
Security
• The security as set up in the transactional data source might not be the same security
as you expect for reporting
Connecting Data - Prepare
Direct Query – Best practice
Tradeoffs – DQ or Import?
• Data refresh - SSAS partitioning
• Memory limit - Smart compression
• Security
Connecting Data - Prepare
Connecting to SQL Server (an example)
Use Query Editor to further refine our data, if we specified “Transform Data”:
Connecting Data - Prepare
Connecting to SQL Server (an example)
Streamlines “Get
Data”.
JSON Format
(requires escape
characters)
Connecting Data - Prepare
Power BI Custom Connectors
Create your own data connector which can be added to the Get Data menu.
Connect to a data source that may not be supported yet by Power BI Desktop or simplify
access to data marts or other sources
Use your own logic, and use multiple options for credentials, such as Windows, basic, API
Key, and database authentication; and more.
The connector can work in both Import or DirectQuery and works with the gateway.
Created using the same M language used by Power Query; (Power Query SDK is available for
Visual Studio)
Connecting Data - Prepare
Power BI Custom Connectors
What is the primary difference between the two data connectivity modes in
Power BI - Direct Query (DQ) and Import?
Shaping is the act of transforming the data to meet our business requirements
Source data is not changed, all the transformations are applied on the Desktop engine
Shaping Data
Power Query Editor
1 Query Ribbon
The “Home” tab contains the common query tasks including the combination
of queries
The “Transform” tab provides access to common data transformation tasks, such
as adding or removing columns, changing data types, splitting columns, and other
data-driven tasks
Shaping Data
Power Query Editor – Ribbon
The “Add Column” tab provides additional tasks associated with columns such as formatting
column data, adding custom columns or invoking functions
The “View” tab provides access to query settings and the Advanced Editor where we can
develop our own data transformation scripts
Displays the data for the selected query and the current transformation step
Many of the transformations can be directly applied here, namely, column related
It displays a preview of the data and might not display the entire dataset
Shaping Data
Power Query Editor – The Query Settings Pane
Building a Query
• Query Features Inside of
Power BI Desktop
Shaping Data
Available Data Transformations
Transform
• Manage columns • Filter Table
• Reduce rows • Pivot/Unpivot
• Merge/Split columns • Change Data Types
• Group rows in a table • Text/Number/Date Formatting
• Aggregate data from a table • Extract parts of strings
• Use first Row as headers • Fill Rows
• Replace Values • Expand Rows from a related table
• Transpose • Merge Queries
• Reverse Rows • Append Queries
• Count Rows • Combine Binaries
• Conditional Columns
And more …
Shaping Data
Available Data Transformations
Add Column
• Insert Custom Column (also used to
invoke functions)
• Insert Index Column
• Duplicate Column
• Column From Examples
Shaping Data
Available Data Transformations
Perform data cleansing, advanced data shaping, and analytics including completion of missing data, predictions,
and clustering etc.
In some cases, Power BI Desktop will be able to push the transformation work to the data source
If query folding doesn’t happen, all the data has to be loaded into the tool
SELECT 3
[salesordernumber] as [Sales Order Number],
[salesorderlinenumber] AS
[SalesOrderLineNumber],
[salesreasonkey] AS [SalesReasonKey]
FROM
[dbo].[factinternetsalesreason] 1
1 WHERE
[salesorderlinenumber] = 2 2
2
3
Shaping Data
Query folding
• Relational Databases
• Odata
• Exchange
• Active Directory
Use the Advanced Editor to edit the query or Blank Query data source to start from an
empty query
Shaping Data
Query formulas – an example
Parameters are
Functions allow for
The procedure must be declared in the function
code reuse. They
enclosed in a new let definition and then they
require following
and in block can be used to make
syntax:
the procedure generic:
Shaping Data
Query formulas – User Functions
Queries and other objects can use parameters to get a dynamic behavior
Shaping Data
Query Parameters
Can be referenced from other queries and loaded to the data model for use in calculations
Visibility of each of the data profiling elements can be controlled through the
View tab.
Shaping Data
AI Insights Query Editor
Use AI Insights to gain access to a collection of pre-trained machine learning models that
enhance your data preparation efforts.
With Text Analytics and Vision in Power BI, you can apply different algorithms from
Azure Cognitive Services to enrich your data in Power Query.
Power BI makes it simple to incorporate the insights from models hosted on the Azure
Machine Learning service, using straightforward point-and-click gestures
Shaping Data
Query dependency view
• Shaping Data
Questions?
Knowledge Check
After data connections are created and the data is shaped according to the business requirements, we
start modeling it
Calculations can be created for additional context or for implementing business metrics or even key
performance indicators
D
A Data View icon
C
E
B Data Grid – Shows the
data for a selected table
A
C Modeling Ribbon –
Manage relationships,
B calculations, data types,
formats, and
categorization
F
D Formula bar – DAX
formulas for calculations
They connect two tables allowing filtering and calculations using columns from both. No
need to flatten!
They are based on a single column from each table. One table acts as a lookup table
and the other as a referencing table
There is also an auto-detect feature where Power BI desktop will rely on column names and data
types (or constraints defined in the data source) to detect relationships
Creating a Data Model
Relationships - Cardinality
This relationship
indicates that neither of
the tables contain unique
values.
Power BI Desktop will
automatically detect
this and display a
warning.
Creating a Data Model
Relationships - Direction
Single is the typical behavior in star-schemas where dimension tables (lookup) filter fact tables (transactional
tables). filter propagates from one side to the many side of the relationship (Dimension to Fact table). This
allows for slicing and filtering fact data using dimension attributes
Both tables act as if together in a single table, so filtering is possible on either side of the relationship.
Creating a Data Model
Relationships – Direction
In some cases, we may want filter to propagate from many to the one side of
the relationship.
E.g. Show number of products of each color sold by each salesperson.
Wrong result using “Single” direction
Creating a Data Model
Relationships – Direction
In some cases, we may want filter to propagate from many to the one side of
the relationship.
E.g. Show number of products of each color sold by each salesperson.
Correct result using “Both” direction
Creating a Data Model
Relationships – Direction
Don’t turn on “Both” direction for every relation. It is slower and might return
unexpected results
Creating a Data Model
Relationships – Direction
∑ 4700
Creating a Data Model
Relationships – Active and Inactive
It is possible to control which relationship is active by using the Manage Relationships window
It is also possible to use DAX to activate a relationship in a calculation or import the lookup
table more than once
Creating a Data Model
Relationships – Parent-Child
Parent-Child
Key Parent Denormalized
Sintra Lisbon Key District Country Region
Lisbon Portugal Sintra Lisbon Portugal Europe
Portugal Europe
Creating a Data Model
Relationships – Data Quality Issues
If data has null or blank values for the columns that support
relationships either:
• Remove those rows (which might affect statistics and summarizations)
• Define a default value that replaces those values so that a match is made
Autodetect new
relationships after
data is loaded – useful
when adding more
tables to the model
Creating a Data Model
Relationships – DirectQuery
Numeric Types
• Decimal Number – eight byte floating point number. The largest value is 15 digits long and decimal separator can occur anywhere.
• Fixed Decimal Number – It allows 19 digits with 4 digits of precision. The largest value is 922,337,203,685,477.5807 . Digits to the right of the 4 digits of
precision are truncated. Good to avoid rounding errors.
• Whole Number – eight byte integer value. It has no decimal places. It allows 19 digits from -2 63 to 2 63-1 and allows the largest value of the numeric
types.
• Percentage – An input value such as “5%” will be automatically recognized as a Percentage value and converted to a 2-digit precision decimal number
(i.e. 0.05).
Text type
True/False type
Date/Time Types
Categorizing the fields is relevant for geographical fields or for image or URL
fields
By default, Power BI desktop will sort data in a column based on the alphabet
You can mark a custom table as a date table (suppresses OOB date tables)
Must be contiguous
Creating a Data Model
Aggregations
Benefits of Aggregations:
Aggregations are a way to store only • Query performance on large datasets
summarized values in memory, to • Data refresh optimization
provide the fastest access to • Achieve balanced architectures
aggregated data without having to
load your entire dataset into Power BI
Creating a Data Model
Import From Microsoft Excel
Microsoft Excel like Language that allows the extension of the model
with additional business logic
A function always references a column or a table. Filters can be added to filter context of evaluation
A function always returns a value or a table. When a table is returned, further functions should be
applied to obtain a value
The editor has keyboard shortcuts, line numbers, and indent lines. The
experience is very similar to what you have for other Microsoft editors, such as
VS Code.
Calculations
DAX Basics – Creating Calculations
Filter context determines the conditions that filter data, for a particular visualization, and can
be applied on top of Row Context
Row Context
They are persisted in the model and are calculated row-by-row (Row Context)
They increase the size and memory requirements for the model
A calculation or a numeric
field has a “Default A Calculated Column with a
With a different
Summarization” – defines “Default Summarization” of
summarization will appear
how it is aggregated when “Do not summarize” will
with
placed on a visualization, by appear with
default
Calculations
Measures
They can be explicit, where they are the result of a DAX expression. You
cannot control the aggregation for this type.
Calculations
Measures
CalendarYear=2012
Promotion=“Reseller”
Gender=“M”
Accessible via field well, you can change how a numerical value or measure is displayed
Calculations
Advanced Calculations
No Discount Sales =
CALCULATE (
SUM ( FactResellerSales[SalesAmount] );
DimPromotion[EnglishPromotionName] = "No Discount"
)
Calculations
Advanced Calculations
FILTER allows more complex filtering but is less performant than CALCULATE
It follows the relationships in order to filter, so its results are more user-friendly
Calculations
Advanced Calculations
Sales with Big Discount =
CALCULATE (
SUM ( FactResellerSales[SalesAmount] );
DimPromotion[DiscountPct] > 0.1
)
Sales with Big Discount FILTER =
CALCULATE (
SUM ( FactResellerSales[SalesAmount] );
FILTER ( DimPromotion; DimPromotion[DiscountPct] > 0.1 )
)
Calculations
Advanced Calculations
It will iterate each row on the first table and apply the arithmetic
expression.
Useful for row-by-row calculations, correcting TOTALS and hidden
calculations
Might, potentially, be slower than SUM
Calculations
Advanced Calculations
X Functions - Row-by-row
SalesAmountwithSUMX =
SUMX (
FactResellerSales;
FactResellerSales[OrderQuantity] * FactResellerSales[UnitPrice]
)
Calculations
Advanced Calculations
ProductRank =
RANKX ( ALL ( DimProduct[ProductAlternateKey] ); [Sales];; DESC; SKIP )
Calculations
Advanced Calculations
ProductRankEnhanced =
IF (
HASONEVALUE ( DimProduct[ProductAlternateKey] );
RANKX ( ALL ( DimProduct[ProductAlternateKey] ); [Sales];; DESC; SKIP );
BLANK ()
)
Calculations
Advanced Calculations
TOPN ( 10; VALUES ( DimProduct[ProductAlternateKey] ); [Sales]; DESC )
TOP10Products =
CALCULATE (
[Sales];
TOPN ( 10; VALUES ( DimProduct[ProductAlternateKey] );
[Sales]; DESC )
Calculations
Advanced Calculations – Support for Excel Financial Functions
Almost all financial functions that you know and love from Excel are now available in DAX.
The functions have the same name and signature as their Excel counterpart.
These financial functions make it easier to build financial reports and perform otherwise
complex calculations in Power BI
Calculations
Advanced Calculations – Time Intelligence
Many DAX functions exist to support time calculations. There are two types:
Functions that require a CALCULATE
SalesYTD =
CALCULATE ( [Sales]; DATESYTD ( DimDate[FullDateAlternateKey] ) )
SalesYTDNoCalculate =
TOTALYTD ( [Sales]; DimDate[FullDateAlternateKey] )
Calculations
Advanced Calculations – Time Intelligence
SalesLastMonth =
CALCULATE ( [Sales];
DATEADD ( DimDate[FullDateAlternateKey]; -1; MONTH ) )
SalesSamePeriodLastYear =
CALCULATE ( [Sales];
SAMEPERIODLASTYEAR ( DimDate[FullDateAlternateKey] ) )
MonthOverMonth =
DIVIDE ( ( [Sales] - [SalesLastMonth] ); [SalesLastMonth] )
SalesSinceEver =
CALCULATE (
[Sales];
DATESBETWEEN (
DimDate[FullDateAlternateKey];
FIRSTDATE ( ALL ( DimDate[FullDateAlternateKey] ) );
LASTDATE ( DimDate[FullDateAlternateKey] )
)
)
Calculations
Advanced Calculations – Time Intelligence
SalesAmountYTD =
CALCULATE (
SUM ( FactInternetSales[SalesAmount] );
DATESYTD ( FactInternetSales[OrderDate].[Date] )
)
Calculations
Advanced Calculations – Note on Auto date/time
This feature can bloat the data model by creating separate internal
date dimension tables for each date attribute.
For large tables, bring your own Date table and mark it as Date Table.
Calculations
DAX Variables
Variables makes writing DAX code easier, increases readability, reusability and maintenance of DAX code.
Syntax:
• VAR keyword introduces the definition of a variable
• RETURN keyword defines the expression to return as the result
myFormula =
VAR = VariableName1 = <some valid DAX formula>
VAR = VariableName2 = <some other valid DAX formula>
RETURN <another valid DAX formula that can use VariableName1
and VariableName2 as part of the expression>
Calculations
DAX Variables
Can have as many variables in an expression as required, and each one has its own definition
DAX evaluates variables in the context of their definition, not in the one where they are used.
Once the variable has been assigned a value, that value cannot change during the execution of the RETURN portion of
the formula
The results of the variable calculations are cached for reuse inside the formula
To calculate a percentage of year-over-year growth without using a variable, we could create three separate
measures:
Sum of SalesAmount = SUM(SalesTable[SalesAmount])
SalesAmount PreviousYear=CALCULATE([Sum of SalesAmount], SAMEPERIODLASTYEAR(Calendar[Date]))
Sum of SalesAmount YoY%=DIVIDE(([Sum of SalesAmount] – [SalesAmount PreviousYear]), [Sum of SalesAmount]))
Using a variable, we can create a single measure that calculates the same result
Advantages:
Start with an element on the field well or on the field list and create calculation
Calculations (optional)
Disconnected Tables
(optional)
Power BI Desktop
What are some of the differences between Calculated Columns and Calculated
Measures?
Use drag-and-drop and search to build your analysis like a pivot table in Excel
Building a Report
Modern Ribbon
Clustered Column Stacked Area Line and Stacked Column Map Multi-row Card
Data labels make a chart easier to understand, because they show details about
a data series or its individual data points.
Building a Report
Common visual properties - Bar chart controls
Analytics pane will be the central location for all analytical features
It is possible to sort data according to numeric values or to data categories, for each visualization
For categories, the order that is used is either alphabetical (or numerical) or the custom sort order
You can link a specific website through an image, shape or button. You can do this by selecting
the Web URL option in the Type dropdown of the Action card of the formatting pane.
Building a Report
Wallpapers
The color palette will be applied to all visualizations (except if custom data points
were defined)
The most common options of your current theme can be customized through a dialog in Power BI Desktop
instead of needing to write or modify a JSON file.
The settings that can be customized are divided into different categories like name and colors, text, visuals,
page settings
Page Background
Page Size and
Name (both color and
Format
image)
Building a Report
Hidden pages
Right click on Page and select “Hide Page” to hide it in Reading View
Hidden Pages still shown on Design View, but look different to indicate they are hidden
Snap to gridlines
Demonstration
Clicking or drilling on
You can multi-select A tooltip displays the
a visualization element, Click an empty space
data points across highlighted portion
filters other to clear the filter
multiple visualizations and the total
visualizations
Building a Report
Interactive Features - Cross-Filtering and Cross-Highlight
Click a visualization, the master, and on the other visualizations select the type of interactivity
Filter experience
• Dedicated filter pane with advanced options.
Building a Report
Interactive Features - Report Filtering
Formatting options for the filter pane to make it feel like part of the
report
Filter pane search allows you to search across your filter cards.
Filtering pane Report consumers can see a read only view of filters that are
configuration affecting the visual.
and
customization Hover over a filter icon in the visual header to see the filters, slicers,
features cross-highlighting state that is affecting the data on the visuals.
(cont.): Can turn on this new filter icon through filter formatting options.
Building a Report
Interactive Features - Report Filtering
Radio buttons and allows one and only one filter selection
Sync slicers allows You can set this Hidden slicer will be Create custom Supports standard
the applications of behavior through put on every page, groups of slicers to OOB slicer visual and
filters to multiple the “Sync slicers” and you can control sync under some custom visual
pages pane visibility Advanced options like Hierarchy slicer
Building a Report
Query reduction
Like in Excel, it is possible to drill on specific elements of a matrix, whether on columns or rows
Building a Report
Map visuals – Bubble map
Heat map formatting option for circle Bing map visual converting all the location
dots on your map to a heat map layer through the formatting pane.
Building a Report
Map visuals – Filled map
Building a Report
Map visuals - ArcGIS
Plus
Sign up / Sing
subscription
in to ESRI PLUS
provides
or connect to
additional base
ArcGISOnline
map and
from the ArcGIS
global
Visualization
demographics
ArcGIS Online
Can put up to
provides secure
5,000 geo
organizational
locations on
data for your
your map
reports
Building a Report
Map visuals – Shape map (Preview)
Shows relative
comparisons of regions Based on
Supports custom maps
on a map by coloring ESRI/TopoJSON maps
them differently
Building a Report
Visualizations – ML Script visuals
Used to perform root-cause analysis by viewing how individual categories in a group contribute to the whole.
The visual lets you decompose, or break down, a group to see its individual categories and how they can be
ranked according to a selected measure, such as by sales amount.
Building a Report
Advanced visualizations - Key Influencer Visual
After you build them, you can use them or you can
share with the community
Conditional formatting
Building a Report
Visualizations – Custom Visualizations
Download the visual from store (AppSource) or from file (.pbiviz file
extension)
OR
Building a Report
Visualizations – Custom Visualizations (examples)
Pin any marketplace visual to your pane and have it show up automatically for you every time you open any report
Makes it very easy to standardize on a visual without needing to add it to every single report
Custom Visuals
Building a Report
Interactive Features - Drill down and up
It is possible to navigate across attributes if they are stacked on a particular area of a visualization (down/up/across)
Those attributes don’t have to be natural hierarchies, all of them can be mixed.
Drill up
Expand All down one
level in the hierarchy
Go to the next level
in the hierarchy
Toggle drill mode
Building a Report
Interactive Features - Drill to records
Use Visual table to view the data in a visual as a table, or use Data point table to view a table of the data used to
calculate a single data point
Building a Report
Interactive Features - Drill through
It is possible to create a page in your report that focuses on a specific entity - such as a supplier, or
customer, or manufacturer.
With that focused report page, users can right-click on a data point in other report pages, and drill
through to the focused page to get details that are filtered to that context.
Drill through option on the visual Adding the drill through fields
Building a Report
Interactive Features - Drill through
• Right-click on a data point • Conditionally set the drill through destination for the button
configured for drill through • Conditionally format the tooltips for the enabled and
disabled button state
• A context menu appears, letting
• Individually customize the formatting for the disabled state of
you drill through to that page.
the button
Building a Report
Interactive Features - Drill through (Measures)
Can be used to refer other reports in the same workspace. Through this
you can setup links between reports in the same workspace.
Steps to enable
• Set up a drillthrough target page to be accessed from other reports within a workspace.
• Allow a report to opt into seeing drillthrough pages outside of the
report.
• In the Report settings for the current file section of the Options dialog, enable the Cross-
report drillthrough setting for all reports within a workspace that you want to point that
cross-report drillthrough page
Building a Report
Interactive Features - Bookmarking
Assign actions like ‘back’, bookmark, Q&A, page navigation and drill through to
buttons
Control format of buttons including text, fill color, hover style, filling with images
( for ex disabled, hover, click ) and more
Recommendations for
Improving Results
Building a Report
Interactive Features – Tooltips
Capability to design a report page to be used as a custom tooltip for other visuals in your report
Full flexibility to design whatever kind of custom tooltips you want, from using cards to show detailed
information to miniature drill through pages shown on hover
HOW TO USE:
Clustering lets you quickly find groups of similar data points in a subset of your data
Building a Report
More reporting features - Forecasting
You can use the forecasting feature on your line chart to do predictive analytics on
your data.
Shows date hierarchy in the field list and allows individual selection
Building a Report
More reporting features - Increase/Decrease Insights
Ask us to explain why the data point increased or decreased compared to the data point before it.
machine learning
algorithms
waterfall chart,
scatter chart,
stacked column
chart or
the ribbon chart
Building a Report
More reporting features - Mobile report layout
After publishing, anyone who views this report on their Power BI mobile
app will see the phone layout of the report
The ability to overlay visuals makes it possible for you to use the same
design techniques you use in web layout to create beautiful, interactive,
mobile-optimized reports.
Building a Report
Row-Level-Security (Creation)
Define roles and rules within Power BI Desktop to restrict the data users see
Supported for both Imported models and DirectQuery connections
Rules (or filters) defined within roles restrict data at the row level
Rules are defined using DAX
Building a Report
Row-Level-Security (Validation)
Note that users are assigned to a role within the Power BI service after the solution is
published
Building a Report
Incremental Refresh – PRO + Premium
Filtering needs to be done using Power Query date/time parameters with the
reserved names RangeStart and RangeEnd
Building a Report
Performance Analyzer
Empower your end-users to explore and personalize visuals all within the consumption
Consumer capabilities:
The data model, its data, and reports are uploaded to the service
Sharing
Publish to the Cloud
Any changes made in the report after this or made in the service will not be synced
They are generated from existing PBIX files and contain everything, except the data
They are Exported and Imported (also with double-click on template file) via the File Menu
When a template is instantiated, the data is re-read, so the credentials of the current user can be used and any
parameters will have to be input.
You can set this in Power BI Desktop through the options dialog
under Report settings.
Demonstration
Using Templates
Questions?
Knowledge Check