Context Transition

Power BI · DAX (Data Analysis Expressions)

Theory

Context transition is what happens when CALCULATE runs inside a row context: the values of the current row are turned into filters. Every measure reference has an invisible CALCULATE around it, so referencing [Total Sales] inside a calculated column or an iterator also triggers context transition.

In a calculated column on Customers, SUM(Sales[Amount]) has no filter context, so every customer gets the grand total ₹6,200. Writing [Total Sales] (or CALCULATE(SUM(Sales[Amount]))) instead turns the current row, CustomerID = C1, into a filter that flows through the relationship to Sales, giving Asha ₹2,700, Ravi ₹2,400, Meera ₹600 and Karan ₹500. The same mechanism makes AVERAGEX(Customers, [Total Sales]) compute an average per customer. Context transition is powerful but can be expensive on large tables, and if the iterated table has duplicate rows, each duplicate filters the same rows and results can be multiplied.

Why we use it

It explains why a measure behaves differently from its raw formula inside a column or iterator, and it is the key to per-customer or per-product calculations.

When to use it

Use it intentionally: reference measures inside iterators over dimension tables (Customers, Products) to get per-entity results. Avoid iterating large fact tables with measure references, which forces a transition for every row.

How it works

  1. Row context exists (column or iterator)
  2. Is CALCULATE or a measure reference used? Yes: Row values become filter context. No: Expression sees no row filters.
  3. Filters flow through relationships to related tables
  4. Aggregation runs on the filtered rows
  5. Per-row result

Syntax

Triggered by: CALCULATE(<expr>) inside a row context, or any [Measure] reference inside a row context
Customers[Customer Sales] = [Total Sales]            // with transition
Customers[Wrong Sales] = SUM(Sales[Amount])          // no transition → grand total

Example

// Calculated columns in Customers
Customer Sales = [Total Sales]                   // Asha 2,700, Ravi 2,400 …
Wrong Sales    = SUM(Sales[Amount])              // 6,200 on every row

// Measure: average sales per customer
Avg Sales per Customer = AVERAGEX(Customers, [Total Sales])
// (2,700 + 2,400 + 600 + 500) / 4 = 1,550

Key points

Power BI topics

Power BI Introduction

Getting Data

Power Query (Data Transformation)

Data Modeling

DAX (Data Analysis Expressions)

Data Visualization

Dashboards & Reports

Power BI Service

Advanced Features

Projects & Case Studies

Interview & Certification

Advanced DAX & Time Intelligence

T
Tech Town
Log InSign Up Free
Home SQL Python DSA Power BI Snowflake Databricks Spark Gen AI Practice Problems Contest Blog

Power BI Dashboards & DAX

Learn data visualization and interactive dashboards step-by-step. Click any topic in the sidebar to open it right here.

{{ sectionCount }}
Sections
{{ topicCount }}
Topics
Free
Forever
Hands-on practice Practice DAX Online 250 business scenarios on a star schema — write a measure and compare your visual with the expected one. Start practising →
Section {{ sec.num }}

{{ sec.label }}

Power BI  /  {{ current.sectionLabel }}  /  {{ current.name }}

{{ current.name }}

Theory

{{ current.def }}

Why we use it

{{ rich.why }}

When to use it

{{ rich.when }}

Diagram

{{ rich.dg.caption }}

{{ tb.title }}
{{ c.v }}
{{ rich.dg.op }}
➜
{{ rich.dg.output.title }}
{{ c.v }}
{{ nd.label }}
{{ nd.sub }}
{{ nd.label }}
{{ nd.sub }}
{{ rich.dg.left.title }}
{{ it }}
{{ rich.dg.right.title }}
{{ it }}
On screen — where to click

{{ rich.ui.title }}

{{ u.text }}
  1. {{ st.n }}{{ st.text }}
{{ rich.ui.title }}
{{ u.text }}
Flowchart — how it works
{{ nd.text }}
{{ nd.text }}
◇ {{ nd.text }}
Yes → {{ nd.yes }}
No → {{ nd.no }}
Syntax / Where to find it
{{ current.syntax }}
Example
{{ current.example }}
What You'll Learn — click to check off
  • {{ pt.mark }} {{ pt.text }}

Share this topic