Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
9 |