0% found this document useful (0 votes)
135 views

PL 300T00A ENU Powerpoint 03

Uploaded by

pushkar72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views

PL 300T00A ENU Powerpoint 03

Uploaded by

pushkar72
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

Model data with

Power BI
Desktop

aka.ms/PL300-3

© Copyright Microsoft Corporation. All rights reserved.


Agenda

• Introduction to data modeling


• Manage relationships

© Copyright Microsoft Corporation. All rights reserved.


Introduction to
data modeling

© Copyright Microsoft Corporation. All rights reserved.


Data table types

Fact tables are activities or events. Dimension tables provide the details.

© Copyright Microsoft Corporation. All rights reserved.


Understand star schemas

© Copyright Microsoft Corporation. All rights reserved.


Manage
relationships

© Copyright Microsoft Corporation. All rights reserved.


Create relationships

© Copyright Microsoft Corporation. All rights reserved.


Edit relationships

© Copyright Microsoft Corporation. All rights reserved.


Implications of circular relationships

© Copyright Microsoft Corporation. All rights reserved.


How to use hierarchies for data fields

© Copyright Microsoft Corporation. All rights reserved.


Lab: Design a data model in Power BI Desktop

This lab should take approximately 45


minutes
Configure data In this lab, you’ll commence developing the data
model - GitHub model. It will involve creating relationships between
exercise
tables, and then configuring table and column
properties to improve the friendliness and usability
of the data model.
• Create model relationships
• Configure table and column properties
• Create hierarchies and quick measures

© Copyright Microsoft Corporation. All rights reserved. © Copyright Microsoft Corporation. All rights reserved.
Knowledge check: data models
What is the difference between a fact table and a dimension table?
⃣Fact tables contain observational data while dimension tables contain
information about specific entities within the data.
⃣Fact tables contain information about specific entities while dimension
tables contain information about observational data.
⃣There is no difference.

How do you describe a star schema?


⃣Fact and dimension tables with no relationships between them.
⃣Multiple fact tables with relationships to one dimension table.
⃣Multiple dimension tables with relationships to one fact table.

© Copyright Microsoft Corporation. All rights reserved.


Recap
In this section, we covered:

Fact and dimension tables.


Designing a star schema layout.
How relationships connect tables.
Managing relationships.
Creating hierarchies.

© Copyright Microsoft Corporation. All rights reserved.


Create calculations
with DAX in Power
BI

aka.ms/PL300-4

© Copyright Microsoft Corporation. All rights reserved.


Agenda

• Introduction to DAX
• Advanced DAX concepts
• Optimize DAX performance

© Copyright Microsoft Corporation. All rights reserved.


Introduction to
DAX

© Copyright Microsoft Corporation. All rights reserved.


What is DAX?

• Data Analysis Expressions

• Library of functions and

operators

• Build formulas and expressions

• Create calculated measures,

columns, and tables

© Copyright Microsoft Corporation. All rights reserved.


Create calculated measures

• Defined with DAX

definitions
• Computed on the fly.

• Not stored in data model.

• Responsive to interactions.

• Indicated by calculator icon.

© Copyright Microsoft Corporation. All rights reserved.


Implicit vs. Explicit vs. Quick measures

© Copyright Microsoft Corporation. All rights reserved.


Create calculated columns

• Defined using DAX expressions.

• Computed & stored in data

model.
• Useful “helper/connector

columns.”
• Recalculated during data

refresh.
• Table and Sigma icon.
© Copyright Microsoft Corporation. All rights reserved.
Create calculated tables

• Defined using DAX

expressions.
• Computed & stored in data

model.
• Useful for aggregating data or

creating custom tables.


• Table and calculator icon.

© Copyright Microsoft Corporation. All rights reserved.


Columns vs. measures

Calculated columns: Measures:


• Create values for each row in • Calculate on demand.
table.
• Calculated based on filters.
• Store values in the .pbix file.
• Doesn’t affect data model
• Increases data model size. size.
• Row-by-row calculation can • DAX expressions may still
impact performance. be suboptimal.
• Must be referenced with • Can reference other
measures for reuse. measures directly for
reuse.
© Copyright Microsoft Corporation. All rights reserved.
Lab: Create DAX calculations in Power BI Desktop (45
min)
Create DAX calculations | GitHub exercise

In this lab you’ll create calculated tables,


calculated columns, and simple measures
using Data Analysis Expressions (DAX).

In this lab you learn how to:

• Create calculated tables

• Create calculated columns

• Create measures

© Copyright Microsoft Corporation. All rights reserved. © Copyright Microsoft Corporation. All rights reserved.
Knowledge check: DAX calculations
Which statement about measures is correct?
⃣Measures store values in the data model.
⃣Measures can reference columns directly.
⃣Measures can reference other measures directly.

Which of the following statements describing similarity of measures


and calculated columns in an Import model is true?
⃣They can achieve summarization of model data.
⃣They store values in the data model.
⃣They're evaluated during data refresh.

© Copyright Microsoft Corporation. All rights reserved.


Advanced DAX concepts

© Copyright Microsoft Corporation. All rights reserved.


Understanding filter context
Measures are contextually different, or “dynamic,” depending on filters.

© Copyright Microsoft Corporation. All rights reserved.


CALCULATE() function
Adjusts how measures interpret data filters, enabling context control.

Total Sales for 2015 =


CALCULATE (
SUM ( 'Sales OrderDetails'[Total
Price] ),
YEAR ( 'Sales
OrderDetails’[OrderDate] ) = 2015
)

© Copyright Microsoft Corporation. All rights reserved.


Use inactive relationships with DAX
Enable additional table filtering without impacting the active relationship.

Sales by Ship Date =


CALCULATE (
Sales[TotalPrice],
USERELATIONSHIP (
'Calendar'[Date], Sales[ShipDate])
)
© Copyright Microsoft Corporation. All rights reserved.
Semi-additive
measures
• Context-dependent:
Results vary based on
dimensions.
• Time Intelligence:
Useful for averages, ratios,
balances.
• Caution with aggregation:
Beware of misleading results Last Sales Quantity =
when aggregating. CALCULATE(
SUM(Sales[Quantity]),
LASTDATE('Date'[Date])
)

© Copyright Microsoft Corporation. All rights reserved.


Create a common date table

© Copyright Microsoft Corporation. All rights reserved.


Time Intelligence functions
Total Sales Previous Month =
CALCULATE ( SUM ( Sales[Total
Price] ), PREVIOUSMONTH
( 'Date'[Date] ) )

© Copyright Microsoft Corporation. All rights reserved.


Lab: Advanced DAX calculations in Power BI Desktop
(45 min)
Advanced DAX | GitHub Exercise

In this lab, you’ll create measures with DAX


expressions involving filter context
manipulation.

In this lab you learn how to:

• Use the CALCULATE() function to

manipulate filter context

• Use Time Intelligence functions

© Copyright Microsoft Corporation. All rights reserved. © Copyright Microsoft Corporation. All rights reserved.
Knowledge check: advanced DAX

What DAX function lets you use inactive relationships?


⃣USERELATIONSHIP
⃣DEACTIVATEFILTERS
⃣OVERRIDECONNECTION

Which type of functions specifically use dates for calculations?


⃣Date and Time
⃣Time Intelligence
⃣Filter

What kind of measure sums for one dimension and uses another
aggregation for a different dimension?
⃣Summarized
⃣Aggregated
⃣Semi-additive

© Copyright Microsoft Corporation. All rights reserved.


Optimize DAX
performance

© Copyright Microsoft Corporation. All rights reserved.


Use variables to improve performance and readability
Without variable:
Sales YoY Growth =
DIVIDE (
( [Sales] - CALCULATE ( [Sales], PARALLELPERIOD ( 'Date'[Date], -12,
MONTH ) ) ),
CALCULATE ( [Sales], PARALLELPERIOD ( 'Date'[Date], -12, MONTH ) ) )
With variable:
Sales YoY Growth =
VAR SalesPriorYear = CALCULATE ( [Sales], PARALLELPERIOD ( 'Date'[Date], -12,
MONTH ) )
VAR SalesVariance = DIVIDE ( ( [Sales] - SalesPriorYear ), SalesPriorYear )
RETURN
SalesVariance
© Copyright Microsoft Corporation. All rights reserved.
Tune report
performance
Performance analyzer in Power BI
Desktop

• Record report interactions.

• Review query and rendering

times.
• Identify bottlenecks, optimize

queries.

© Copyright Microsoft Corporation. All rights reserved.


Analyze query plans for optimization opportunities
Count Customers = Count Customers =
CALCULATE ( CALCULATE (
DISTINCTCOUNT DISTINCTCOUNT
( Order[ProductID] ), ( Order[ProductID] ),
FILTER ( Order, Order[OrderQty] >= KEEPFILTERS (Order[OrderQty] >=
5 ) 5 )
) )

© Copyright Microsoft Corporation. All rights reserved.


Knowledge check: DAX optimization

What benefit do you get from analyzing the metadata?


⃣The benefit of analyzing the metadata is that you can clearly identify
data inconsistences with your semantic model.
⃣The benefit of analyzing the metadata is to get familiar with your
data.
⃣The benefit of analyzing the metadata is to know the number of
rows, columns and tables being loaded into your model.
Which of the following statements about relationships in Power BI Desktop
is true?
⃣Relationships can only be created between columns that contain the
same data type.
⃣Relationships can only be created between tables that contain the
same number of rows.
⃣Relationships can be created between tables that contain different
types of data.

© Copyright Microsoft Corporation. All rights reserved.


Recap
In this section, we covered:

What DAX is and how to use it.


Creating calculated measures, columns, and tables with DAX.
Benefits of measures vs. calculated columns.
How filter context and CALCULATE() function affect measures.
Inactive relationships and semi-additive measures.
Creating a common date table and Time Intelligence functions.
Using variables and Performance analyzer for performance.

© Copyright Microsoft Corporation. All rights reserved.


Thanks
Resources

Design a data model in Power BI


Write DAX formulas for Power BI Desktop models

Add measures to Power BI Desktop models

Use DAX time intelligence functions in Power BI Desk


top models

You might also like