Lecture Notes: Advanced DAX Concepts
Session Overview
- Session Repeat Announcement
- Morning session is repeated at 4:40 p.m. and again tomorrow morning at 10:10 a.m.
- Focus on introduction to DAX for those who missed it.
Advanced DAX Introduction
Key Concepts in DAX
Evaluation Contexts
- Evaluation Context
- The most challenging part of DAX to grasp.
- Consists of row context and filter context.
- Evaluation context affects the visibility of data for calculations.
Filter Context
- Determines which subset of data is visible for calculations.
- Examples:
- Slicer filters data subset seen by a report or a pivot table.
Row Context
- Iterating over a table row-by-row.
- Can be introduced by calculated columns or iterators (e.g., SUMX, AVERAGEX).
- Needed to evaluate column values.
Practical Examples
Calculating Rankings
- Task: Compute a ranking for products based on list price.
- Count the number of products with a price greater than the current product.
- Introduce variables to simplify calculations.
Using CALCULATE
Context Transition
- Concept:
CALCULATE
transforms row context into an equivalent filter context.
- Essential when converting row context into filter context for accurate calculations.
Measure vs. Column Context
- When calling a measure, an implicit
CALCULATE
is applied, affecting filter context.
Filter Context Propagation
- Direction
- In Power Pivot: Propagates from one side to many side only.
- In Power BI: Can be set to propagate both ways.
Time Intelligence in DAX
- Requires a complete calendar table.
- Example: Year-to-date calculation by modifying filter context to include all relevant dates.
Conclusion
- Focus on mastering evaluation contexts for effective DAX usage.
- Reference: "Definitive Guide to DAX" for more advanced topics.
These notes cover the essentials from Alberto Ferrari's presentation on advanced DAX concepts. Understanding evaluation contexts and the use of CALCULATE
are critical for mastering DAX.