Sunteți pe pagina 1din 22

Module 6

Creating and Formatting Measures


Module Overview

• Data Analysis Expressions


• Measures
• Advanced DAX Functions
Lesson 1: Data Analysis Expressions

• Reviewing DAX
• Using the CALCULATE and ALL Functions
• Demonstration: Adding a Calculated Column in
the Data Model
Reviewing DAX

• Comparing DAX to Excel formulas


• Where to use DAX
• Calculated columns
• Measures

• Context
• Row context
• Filter context

• DAX function categories


Using the CALCULATE and ALL Functions

• CALCULATE
• ALL
• Using CALCULATE and ALL to determine
proportions:

SalesShare: =
( SUM('SalesItems'[TotalDue]) )
/ CALCULATE( SUM('SalesItems' [TotalDue],
ALL('SalesItems') ) )
Demonstration: Adding a Calculated Column in
the Data Model

In this demonstration, you will see how to:


• Add a calculated column to a table in the Data
Model
• Use a DAX expression in a calculated column
Lesson 2: Measures

• What Is a Measure?
• Creating Measures
• SUMX, AVERAGEX, and COUNTX
• Demonstration: Adding and Using Measures
What Is a Measure?

• Measures aggregate values in the current context


• Choosing a measure
• Default measures for a data type

1.34
Values in Measure Result PivotTable or
Context PivotChart
Creating Measures

• Creating measures in the Power Pivot for Excel


window
• Creating measures in the PivotTable Fields Task
pane
• Implicit and explicit measures
SUMX, AVERAGEX, and COUNTX

• Table input functions


• Functions that return tables
• Example: calculating an average over a filtered
table

AverageTaxOutsideUS:=
AVERAGEX(
FILTER('Orders', [Country]<>"USA"),
[TotalIncTax] – [TotalExTax]
)
Demonstration: Adding and Using Measures

In this demonstration, you will see how to:


• Create a new measure in the Data Model
• Use the AVERAGE and AVERAGEX functions
• Use a measure in a PivotTable
Lesson 3: Advanced DAX Functions

• Time Intelligence Functions


• Statistical Functions
• Filter Functions
• Other Functions
• Demonstration: Adding a Complex Measure
Time Intelligence Functions

• Functions that return a single date


• Functions that return a table of dates
• Functions that evaluate an expression over a time
period

06/10/2016 – 06/26/2016

SAMEPERIODLASTYEAR

06/10/2015 – 06/26/2015
Statistical Functions

• AVERAGE
• AVERAGEA
8, 1, , 4, 6, 18, 5, 4, TRUE, 21, 32
• COUNT
• COUNTA
• COUNTBLANK COUNT
• COUNTROWS
• MAX 9
• MIN
• STDEV.S
• STDEV.P
Filter Functions

• DISTINCT
• FILTER
8, 1, 4, 6, 18, 5, 4, 18, 8, 32
• FILTERS
• RELATED
• RELATEDTABLE DISTINCT

8, 1, 4, 6, 18, 5, 32
Other Functions

• Information functions
• Logical functions
• Math functions
• Text functions

" Text with irregular spaces "

TRIM

"Text with irregular spaces"


Demonstration: Adding a Complex Measure

In this demonstration, you will see how to:


• Use the FIND function to search for a string
• Use the RELATED function to return a column in a
related table
• Use the FILTER function to remove nonmatching
rows from a table
Lab: Creating Measures by Using Advanced DAX
Functions

• Exercise 1: Last Year Comparison Measures


• Exercise 2: Year to Date Measures
• Exercise 3: Market Share Measure

Logon Information
Virtual machine: 20779B-MIA-CLI
User name: Student
Password: Pa55w.rd

Estimated Time: 45 minutes


Lab Scenario

You have been provided with sales data imported


from a company database into a Data Model in an
Excel spreadsheet. The data includes information
from three database tables and a date table has
been added. The board of your company has said
that they are interested in the following
information:
• How sales have changed year-on-year.
• How sales are performing in the year to a
particular date.
• The market share for the manufacturer VanArsdel.
Lab Scenario (Continued)

You have been asked to add suitable measures to


the Data Model that make it easy for analysts to
view this information.
Lab Review

• What was the total percentage sales change you


calculated for all countries?
• What was the percentage year to date sales
change you calculated for France?
• What was VanArsdel’s market share in Germany?
Module Review and Takeaways

• Review Question(s)

S-ar putea să vă placă și