Forum Discussion

smoortema's avatar
smoortema
Frequent Visitor
2 years ago
Solved

Context transition for INDEX() function

I wrote the following code to have a table where I can see, for each customer the price plan code they had at the moment of their last transaction. The code seems to work well now. However, I do not...
  • AlexisOlson's avatar
    2 years ago

    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