Get Into Evaluation Context With DAX
Get Into Evaluation Context With DAX
Get Into Evaluation Context With DAX
Reeves Smith
Linchpin People
Objective
Reeves Smith
reeves.smith@macerconsulting.com or linchpinpeople.com
@SQLReeves
http://reevessmith.wordpress.com
www.linkedin.com/in/reevessmithiii
Who are you
Introduction
Measures vs. Calculated Columns
Evaluation Context
Multi-Table Evaluation Context
Questions
References
DAX Introduction
What is DAX?
Data Analysis eXpressions
DAX Expressions
Columns – [SalesAmount] or InternetSales[SalesAmount]
Tables – InternetSales
DAX Syntax
=[ColumnName] or =[Measure]
Recommend Best Practice for naming Measures/Calculated Fields
=TableName[ColumnName]
Recommend Best Practice for naming Calculated Columns
='Table Name'[ColumnName]
=[TableName].[ColumnName] Not MDX
Column names must always be enclosed in brackets
Table names cannot be enclosed in brackets
Calculated Columns vs. Measures
Calculated Columns
Table Column Calculated
Columns
Calculated
Columns
Calculated Columns
Need to use in Slicer or on Rows and Columns
Expression that is strictly bound to current row
Categorize/Discretization
Measures/Calculated Fields
Calculate Percentages
Calculate Ratios
Save Storage Space
Evaluation Context
“To get the best from DAX, you need to understand the evaluation
context.”
Alberto Ferrari, Marco Russo or Chris Webb
SQL Server 2012 Analysis Services the BISM Tabular Model
=SUM( FactInternetSales[SalesAmount] )
It depends…
Evaluation Context Types
* Query context only referenced by Microsoft and I have not seen it used in any other
documents.
Row Context
Defined by Calculated Column
Row Context Functions
AVERAGEX()
COUNTX()
MINX()
MAXX()
SUMX()
EARLIER()
FILTER()
SUMX() Function
CALCULATE()
CALCULATETABLE()
FILTER()
ALL()
ALLEXCEPT()
ALLSELECTED()
VALUES()
FILTER() Function
Excel 2010/2013
PowerPivot Window – Table Filters
Testing Evaluation Context
RELATED(Products[ListPrice])
1
Products
∞Orders
Row Context – Multiple Tables
1
Products
∞Orders
Filter Context – Multiple Tables
1
Products
∞
Orders
Filter Context – Multiple Tables
1
Products
∞
Orders
Model Comparisons
1
Products
∞
Orders
Demo – Multi-Table Row and Filter Context
Questions
http://www.powerpivotpro.com/2013/02/guest-post-from-ken-puls-how-to-buy-
powerpivot-2013-including-the-30-volume-licensing-workaround/
reeves.smith@macerconsulting.com or linchpinpeople.com
@sqlreeves
http://reevessmith.wordpress.com
www.linkedin.com/in/reevessmithiii