Context Transition and Inflated Numbers

Someone asked this question on Stack Overflow, and I think it will be a good learning for anyone who is new here:

Context Transition is a process which transforms all the columns of the currently iterated row into an equivalent filter context, which in turn filters the model. We think that only explicitly mentioning CALCULATE can initiate Context Transition but the truth is every measure has a hidden CALCULATE around it:

So your code

Actuals with sign =
SUMX (
    'Accounts',
    [Actuals] * 'Accounts[sign]'
)

Is internally transformed into :

Actuals with sign =
SUMX (
    'Accounts',
    CALCULATE ( [Actuals] ) * 'Accounts[sign]'
)

The problem is if you don’t have at least 1 column with unique values then the result returned after context transition is inflated as when it is time to filter the model duplicated rows are transformed into filter context 1 by 1 and then they filter the rows that have been iterated earlier. Because internally there is not concept of Previous or Next, the engine only knows that it has to filter the model.

So if you have 2 duplicated rows, row 1 and 5 then at row 1 Context Transition will filter row 1 and row 5 and at row 5 Context Transition will filter row 5 and row 1 and then SUMX will SUM the values which will inflate the numbers.

Here is a small representation of how it happens:

4 Likes

marking closed.

1 Like

great explanation. thank you