Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Solved! Go to Solution.
The filter argument for CALCULATE (the INDEX(...) part in your case), is evaluated before the context transition happens. In order for the Customer ID row context from ADDCOLUMNS to affect the Transactions table inside INDEX, you need to force a context transition to happen using CALCULATETABLE. (The outer CALCULATE does not suffice because Transactions is part of the filter argument, not the expression to be evaluated within that filter context.)
See this article for more detail on exactly this topic: Context Transition and Filters in CALCULATE - SQLBI
Thanks!
Is there a simpler, more efficient way to achieve the same result? I use this table for a measure that calculates the number of active customers, sliced by the price plan they were in for their last transaction in the selected period.
There are plenty of other ways to do this but I'm not sure what is the most efficient for your particular model.
Here's another option to try:
FILTER (
SUMMARIZE (
Transactions,
Transactions[Customer ID],
Transactions[Price plan code],
"@Date", MAX ( Transactions[Date] )
),
CALCULATE (
MAX ( Transactions[Date] ),
ALL ( Transactions[Price plan code] )
) = [@Date]
)
This precalculatest the max date for each customer / code combination in your filter context and then filters it down to just the most recent code.
The filter argument for CALCULATE (the INDEX(...) part in your case), is evaluated before the context transition happens. In order for the Customer ID row context from ADDCOLUMNS to affect the Transactions table inside INDEX, you need to force a context transition to happen using CALCULATETABLE. (The outer CALCULATE does not suffice because Transactions is part of the filter argument, not the expression to be evaluated within that filter context.)
See this article for more detail on exactly this topic: Context Transition and Filters in CALCULATE - SQLBI
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
16 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
23 | |
11 | |
10 | |
10 | |
8 |