Concept Breakdown
In Power BI, a calculated column operates within a row context. When an aggregation function like SUMX is used within a calculated column, it inherently 'sees' the current row's context. This row context is then implicitly converted into a filter context, allowing the aggregation to filter related tables—this process is known as context transition. To calculate a grand total that ignores this row context (or any existing filter context), functions like CALCULATE combined with modifiers such as ALL or REMOVEFILTERS are essential to override the natural filter behavior.
What You Will Learn
Understand when to use SUMX, CALCULATE, ALL in a Power BI model.
Practice the concept inside a real PBIX report rather than only reading syntax.
Complete a intermediate-level task and verify the result with a hidden answer check.
Practice in Power BI
The starter PBIX link has not been attached yet. The student workflow is ready for the admin to connect the file.
Download and unzip the provided Power BI file.
Open the Power BI file and navigate to the 'Product' table.
Create a new calculated column named 'Total sales' that calculates the total sales across the entire database, ensuring it ignores the current product row's context.
Create a second calculated column named 'Sales for product' that calculates the total sales specifically for the product in the current row. This column should leverage context transition implicitly.
Create a third calculated column named 'Product contribution' which calculates the ratio of 'Sales for product' to 'Total sales'.
Verify that your 'Product' table now contains these three new columns with the correct values, matching the provided screenshot.
Save the file as 'Context transition is fun' and close it.
Starter DAX
SUMX( 'TableName', 'TableName'[Column1] * 'TableName'[Column2] )Expected Outcome
The 'Product' table will have three new columns: 'Total sales' (showing the same grand total value for every product), 'Sales for product' (showing unique sales figures for each product), and 'Product contribution' (a percentage indicating each product's share of total sales).